Category Archives: Research

Research I have done, or am doing, posted for the benefit of future generations who might do or be doing the same.

Need help linking Windows C to FTDI static libraries

UPDATE: A support person with FTDI reached out to me, and confirms their static library can only be used with Microsoft’s compiler. It will not work with GCC, etc. That is the root of my issue. My next question is going to be: Can I do C code with Visual Studio? More to come…


This should be a simple problem to solve, and this problem may be related to using the wrong compiler (a very old Clang 3.3).

FTDI provides device drivers for things like RS232 interfaces. FTDI drivers typically come with Windows, Linux and Mac. When writing a program to use the FTDI device, they provide header files, DLLs and .libs. These come in a .zip file:

FT4222HQ – FTDI

Inside this zip are two header files. One is for the common FTDI stuff (Open, Close, etc.). The second is for the FT4222 which is a USB-to-I2C chipset.

Both are provided as .libs for DLLs, or static libraries. They also provide 32-bit and 64-bit versions of each.

Header files:

\LibFT4222-v1.4.7\imports\ftd2xx
\LibFT4222-v1.4.7\imports\LibFT4222\inc

64-bit static libraries:

\LibFT4222-v1.4.7\imports\ftd2xx\lib\amd64
\LibFT4222-v1.4.7\imports\LibFT4222\lib\ucrt\amd64

The files I am using in my test project are:

LibTest.c
ftd2xx.h
LibFT4222.h
ftd2xx.lib (681 KB, 64-bit static library)
LibFT4222-64.lib (12,918 KB, 64-bit static library)

There are defines for each of the libraries that are supposed to be set before including the corresponding header file:

#define FTD2XX_STATIC
#define FT4222_STATIC

#ifndef FTD2XX_STATIC
#error FTD2XX_STATICmust be defined to use static libs.
#endif

#ifndef FT4222_STATIC
#error FT4222_STATIC must be defined to use static libs.
#endif

…though I would normally set it in my project settings.

This “should” be simple, but on LabWindows/CVI 2017 (which uses Clang 3.3), it has a two sets of linker errors to some Windows library stuff that I do not know how to resolve.

When I make a project in Code::Blocks which uses GCC, I only get one set of six mangled references.

GCC errors:

..\..\LibFT4222-v1.4.7\imports\ftd2xx\lib\amd64\ftd2xx.lib(x64\Release\FTD2XX.obj):(.text$mn+0xec)||undefined reference to `??3@YAXPEAX_K@Z'|
..\..\LibFT4222-v1.4.7\imports\ftd2xx\lib\amd64\ftd2xx.lib(x64\Release\FTD2XX.obj):(.text$mn+0x16d)||undefined reference to `??3@YAXPEAX_K@Z'|
..\..\LibFT4222-v1.4.7\imports\ftd2xx\lib\amd64\ftd2xx.lib(x64\Release\FTD2XX.obj):(.text$mn+0x1e5)||undefined reference to `??3@YAXPEAX_K@Z'|
..\..\LibFT4222-v1.4.7\imports\ftd2xx\lib\amd64\ftd2xx.lib(x64\Release\FTD2XX.obj):(.text$mn+0x25d)||undefined reference to `??3@YAXPEAX_K@Z'|
..\..\LibFT4222-v1.4.7\imports\ftd2xx\lib\amd64\ftd2xx.lib(x64\Release\FTD2XX.obj):(.text$mn+0x2d5)||undefined reference to `??3@YAXPEAX_K@Z'|
..\..\LibFT4222-v1.4.7\imports\ftd2xx\lib\amd64\ftd2xx.lib(x64\Release\fteepd.obj):(.data$r+0x0)||undefined reference to `??_7type_info@@6B@'|
||error: ld returned 1 exit status|
||=== Build failed: 7 error(s), 20 warning(s) (0 minute(s), 1 second(s)) ===|

Since GCC gets further, I am going to try to use it.

This sample project is just a test to link to Open and Close functions in the FTD2XX library. Nothing is being used in the FT4222 library, so it really is not part of this test, but ultimately I will need it.

My test program is:

#define FTD2XX_STATIC
#define FT4222_STATIC

// -lsetupapi -ladvapi32 -luser32

#ifndef FT4222_STATIC
#error FT4222_STATIC must be defined to use static libs.
#endif

#include <windows.h>

#include <stdio.h>
#include <stdlib.h>

#include "ftd2xx.h" // Add to include path.
#include "LibFT4222.h" // Add to include path.

int main (void)
{
FT_STATUS ftStatus = 0;
FT_HANDLE ftHandle;

ftStatus = FT_OpenEx ((void*)"PrecisePower A",
FT_OPEN_BY_DESCRIPTION,
&ftHandle);

if (FT_OK == ftStatus)
{
FT_Close (ftHandle);
}

return 0;
}

I am posting this to my blog in case someone else is searching for a solution for this.

Meanwhile, if you think you know how to get this to work, please let me know.

IMPORTANT INFO: The FTDI readme says it works in Visual Studio. They have one example they provide that does static linking and it builds just fine. I have not tested it to see if it actually works, and do not know how to tell if it truly is using the static libraries. (We have always used the DLL version of the libraries, and those work fine.)

Is is possible they made a library that will not work in Clang or GCC, but does work in Microsoft’s compiler?

Tips appreciate.

After the Rain / The Passage (1988) – the movie I was almost in.

In 1984, I was moved from Houston, Texas (where I grew up) to deep East Texas. I completed high school there, then moved to Lufkin, TX. That is where I lived when I started Sub-Etha Software with Terry Todd.

An interesting moment in my high school years was when a movie production company came to town to film something in San Augustine. My friend Jeremy (a drummer I played keyboards with) was from San Augustine. A group of us went down to audition to be extras in this movie.

Ned Beatty was in this thing! Apparently they turned the old downtown area in to “really old down town” by covering the streets with dirt and such.

Here is the IMDB listing for the movie:

https://www.imdb.com/title/tt0191764

I do not think any of us saw the movie when it was released in 1988. Just the other day, Jeremy contacted me asking if I knew what was involved in playing a PAL VHS tape. He had located a VHS copy of the movie — from another country. Here is a sub-titled trailer, though the movie is called “The Passage” in this trailer:

The Passage (1988)

When he sent me this, I went searching Ned Beatty’s IMDB page to look up more details. “The Passage” was not listed. I soon learned the movie was also called “After the Rain.” With that information, I was able to locate the IMDB entry and find a few other references to this film.

But, I cannot find any source to stream, rent or buy this film. Lost Media! At least in the USA.

I am posting this in case someone else is searching for it. (I did see one review on IMDB from someone who got to watch a premier of the film in Tyler, TX when it came out.)

Leave a comment if you end up hear after a search…

DJI MIC 2 transmitter works with Insta360 X3 with no adapter needed.

12/9/2024 Update: For search engine visibility, this should also apply to the Insta360 X4 and the new DJI Mic Mini. I will update this post with more details when I remember to do so…

In addition to the new DJI MIC 2 working with the native iPhone camera app, it can also be used directly with an Insta360 X3 360 camera. With the previous DJI MIC or something like the RODE microphone system, you needed to use the microphone receiver and an Insta360 microphone adapter and have it all connected to the camera with a cable.

The DJI MIC 2 adds Bluetooth and you can pair it directly with the X3 just by pairing it as if it were AirPods. (I suppose Insta360 needs to update the firmware to just say “Bluetooth” if it supports devices other than Apple.)

This means a $99 DJI MIC 2 transmitter is all you need for remote audio for an X3 (or iPhone, with an extra step to switch the phone over to using it). There is no need for the receiver and cables unless you are wanting to use more than one microphone at a time (as far as I know, you can only pair one Bluetooth microphone at a time with the phone or X3).

Unfortunately, the DJI firmware disables local backup recording when using Bluetooth, and also disables the new noise elimination feature. This means if anything screws up with the Bluetooth connection, you are out of luck. Pity. Backup recording is one of the features that makes the DJI MIC so useful. Maybe this is a firmware thing they can change in the future.

Until then…

Using the DJI MIC 2 or Mic Mini with the iPhone native camera app

12/9/2024 Update: I have also tested this trick with the new DJI Mic Mini, and it works for that as well.

The DJI MIC 2 can pair to an iPhone via Bluetooth, but the built-in iPhone camera app (the “native camera app”) does not automatically use it. Various YouTubers and web pages and even ChatGPT say you have to use a third-party camera app that allows selecting the Bluetooth microphone.

But that is not true. You can run an app such a RODE Reporter, select the DJI MIC 2 (or DJI Mic Mini), then run the native camera app and it works fine.

Thank you, RichardTaylorTV, for not just echoing the same junk everyone else is doing.

RichardTaylorTV

Canon Camera Connect iOS app v3.0 storing same GPS location in every photo.

I am posting this in case someone else with the same issue is searching for a solution.

The Canon Camera Connect app can record GPS locations, then later upload them to a supported Canon camera where they get embedded in the photo files. Unfortunately, the V3 app has a bug. It appears to store only ONE GPS location in every file taken — the location where the phone was when you click “Start recording” in the app. That GPS location and timestamp will be in every photo (I took 508 photos today and all confirm this; and I had a similar issue last month with it doing it every day for six days).

This is with the iOS version and a Canon G5X phone. The v2 had its own problems, but at least worked well when it worked. I have been using it since 2017.

If you find this post and have this issue, leave a comment with your details.

Migrating from Perforce to Git (BitBucket)

I am placing this information here in case it saves someone else two days of web searching. These steps cover how to do it on Windows and thus have several extra steps that are not needed for Linux and macOS users.

Prerequisites

  1. Perforce installed (with the p4 command line tools).
  2. Git installed: https://git-scm.com/download/win
  3. Python installed: https://www.microsoft.com/store/productId/9PJPW5LDXLZ5

It is assumed you have Perforce set up and authenticated so the p4 command line tool works. It is also assumed you have a remote Git repository like BitBucket also authenticated. I won’t cover those details.

Test the “git p4” command, and fix if needed.

From a command prompt, type “git p4” and see if it works. This relies on a python script called “get-p4” that may need to be edited to work with your version of Python. If you see this:

C:\>git p4
fatal: 'p4' appears to be a git command, but we were not
able to execute it. Maybe git-p4 is broken?

…you will need to edit the file and update the first line to change the reference to “python2” to just be “python”. The file is located here:

C:\Program Files\Git\mingw64\libexec\git-core\git-p4

Change the first line:

#!/usr/bin/python2

…to just be:

#!/usr/bin/python

The original is apparently designed to run only on systems where the python executable is called “python2”.

Step 1 – Clone Perforce in to a local Git repository

Create a directory that will hold your Perforce depot directories, and change in to it:

md FromPerforce
cd FromPerforce

Run the following command (where “xxx” is one of your Perforce depots — such as //depot or //Users or whatever you have). The @all will clone all revisions, and –import-labels is supposed to bring down all tags (this doesn’t seem to work for me):

git p4 clone --import-labels //XXX@all

When finished, you now have a subdirectory that is a local Git repository of all those Perforce files, including version history and commit comments.

Change in to this directory for the next step:

cd XXX

Step 2 – Create a fresh Git repository on BitBucket (or whever)

If you do not already have a Git repository on your remote server (BitBucket in this example), create one. You will need to know the URL of this repository, which is something like:

https://myusername@bitbucket.org/accountname/repositoryname.git

In BitBucket, you get this from the Clone button (it will populate a box with a git clone command line, and you can copy the URL from there).

Step 3 – Pull down the Git repository and rebase, and push the new stuff

git remote add origin https://username@bitbucket.org/accountname/XXX.git

git pull origin master --rebase

git push -u origin --all

(You can use “git remove remote origin” if you need to try this again, due to a type in the URL or something.)

Once that is done, you should be able to see all those Perforce files and their history in BitBucket.

Uploaded Facebook videos not playing sound (but do in preview).

I thought I’d share the solution to a puzzling issue I encountered recently with videos uploaded to Facebook. A recorded video (screen capture) had audio that played fine in my local .mov file, and played fine in the Facebook video preview, but once published, it was silent. No sound.

I tried multiple uploads and several videos, and they all did the same thing. Yet, earlier videos recorded with the same screen capture software, the same way (or so I thought) played audio just fine.

It turns out, Facebook does not support multiple tracks of audio in video files. It uses the first set of audio. I’m my case, the change was using a USB microphone to record my narration instead of the built in laptop mic. The capture software was placing the app audio (built in sound from the computer) on the first set of stereo tracks, and then my USB microphone on the second set. Facebook does not honor any tracks beyond the first set.

Had what I was recording had any app audio, I might have noticed this … “hey, my voice is gone but the beeps are still there.”

But my demo was silent, and it took some web searching to figure this out.

Initially, I got it working simply by taking my captured .mov file and importing it into Final Cut Pro X and then exporting it from there. FCP mixes the multiple audio tracks down to stereo for me, per the output file format.

But, a much easier solution (since I was not using audio on the first track) was to use a utility that would just delete the first unused audio track.

My screen capture software does have an option on how it prioritizes audio recording, so there may be an easy fix I can make there.

I thought I’d post this here in case someone else stumbles upon it.