Connecting to Perfectflite Pnut and Stratologger CF without Perfectflite app

The Rocketry Forum

Help Support The Rocketry Forum:

This site may earn a commission from merchant affiliate links, including eBay, Amazon, and others.

amiliv

Well-Known Member
Joined
Jul 2, 2018
Messages
124
Reaction score
49
I'm trying to see if I can connect to the Pnut and Stratologger with a terminal program, and hoping the interface is ASCII friendly. However, I can't seem to be able to get any response from it in the terminal. I suspect my serial port settings might be wrong (I attempted standard 9600 bps). Does anybody knows serial port settings for the USB DT4U adapter? And/or knows how to communicate with these devices directly (i.e. the "on the wire protocol")?

The reason why I'm trying to do this instead of simply using the Perfectflite app is that it hasn't been updated in a while and it stopped working on newer Macs. This leaves me with few options:
  • figure out how to connect to it directly, hoping for simple ASCII-friendly interface (i.e. the question above),
  • buy a cheap/used Windows laptop to run Windows version of the app on,
  • or retire my old but still perfectly working Pnuts and Stratologger CF's in favor of e.g. Altus Metrum EasyMini.
I'd like to try throwing a bit of time and brain on the problem, before throwing money on it.
 
I’ll be interested in your results. I’ve not yet put a 64-bit-apps-only version of MacOS on my Mac in part because of this. I do have a cheap Windows laptop I take to the field as other devices I fly are Windows only, but I don’t want to lose the ability to download Pnut data to my Mac if I can avoid it.
 
I think I figured out a good chunk of it after playing with it this evening... This should be sufficient to write a simple program to read the data off the Pnut and Stratologger CF. I would not dare going into changing flight settings part, and would definitely not share it... since misconfiguring Stratologger based on information that is guesswork at best can be catastrophic...

Unlike Eggfinder TRS where one can simply connect with terminal application and type away commands, the interface for Perfectflite is not human friendly, unfortunately... It's all binary. So, nope, simple terminal will not do, one would need to write an actual program to communicate with these beasts.

The serial port settings are 57600 bps, 8-bits, no parity, 1 stop bit. I suspect hardware flow control, not sure yet.

Before each command, 0x0d (<CR>) is sent repeatedly until the device responds with 0x2a ("*"). Exception are the block of commands for downloading data ("q", "d" and "e") where <CR> is sent only before the initial "q" command, but not before "d" and "e" commands. Commands are mostly single byte or two bytes, no <CR> or <LF> is sent following the command; the device immediately responds as soon as it receives sufficient number of bytes (one or two, depending on the command).

Each command returns fixed number of bytes; the program needs to know in advance how many bytes each command will return.

Sending 0x69 ("i") returns two bytes. First byte seems to be device ID. 0x01 for Pnut, and 0x03 for Stratologger CF. I suspect second byte is firmware version, with higher 4 bits being major version number and lower 4 bits being minor version number. So 0x01 0x10 is Pnut with firmware 1.0, while 0x03 0x10 is Stratologger CF with firmware 1.0.

Sending 0x66 ("f") returns two bytes. I suspect this is range of "used" flight slots. E.g. if there's 6 used flight slots on the device, you get 0x00 0x06.

Sending 0x67 ("g") returns single byte. This seems to be the slot containing last flight, e.g. 0x06.

Sending 0x73 ("s") returns two byte serial number. E.g. 0x042d for serial number 1234.

Now for the fun multibyte commands. First byte is command, and second byte is flight slot number (e.g. 0x05 for slot 5; this is hexadecimal 5, not ascii code for character 5).

Sending 0x61 ("a") followed by slot number (e.g. 0x61 0x05), the device sends back apogee encoded as 3 bytes, e.g. 0x000412 representing 1042 feet.

Sending 0x64 ("d") followed by slot number, the device returns 8 bytes that I'm not sure what they represent. This command seems to be specific to Stratologger CF. I suspect the first two bytes might be drogue and apogee current in amperes, but I'm not sure.

Sending 0x71 ("q") followed by slot number initiates data transfer. After receiving the "q" command, Pnut returns 4 bytes, while Stratologger CF returns 7 bytes. 2 bytes (as 2-complement, number can be negative) for ground altitude (e.g. 0xffc3 is -61 feet), followed by 2 bytes containing number of samples in the data file (e.g. 0x04f0 if there's 1264 samples). Stratologger CF will additionally return two more bytes for main deployment altitude (e.g. 0x02bc for 700 feet), followed by one more byte (e.g. 0x00) which I suspect might be apogee delay in seconds on that flight.

After that, successive 0x64 ("d") will trigger device to send 48-byte block of flight's data samples. The "d" commands are sent repeatedly until all samples are read (the "q" command above returned how many samples need to be read). The last block of data sent will be padded with 0xff to 48-bytes if it contains less than 16 samples.

Finally, 0x65 ("e") is sent to finish data transfer, and device responds with 0x3f ("?").

Note that there are no 0x0d (<CR>) sent between "q", "d" and "e" commands.

On Stratologger CF each data sample is 6 bytes long (i.e. each 48-byte block contains 16 data samples). First 3 bytes are altitude in feet above ground level (remember that ground altitude was returned by "q" command), followed by two byte temperature in degrees celsius multiplied by 100, followed by 1 byte voltage multiplied by 10. On an example let say 6-byte sample is "0x00 0x03 0x73 0x07 0x17 0x51". This decodes to 883 feet (0x000373 is 883), 18.15 celsius (0x0717 is 1815), and 8.1 volts (0x51 is 81). The altitude is 2-complement and can be negative; I suspect temperature and voltage are also 2-complement.

On Pnut, data samples are encoded same way, each sample is 6 bytes long. Except for voltage. The voltage is still in the last byte of each sample... But it's encoded differently; e.g. 0xe3 which is decimal 227 which doesn't make any obvious sense how that translates to a voltage of a single cell LiPo battery...

There is no time information stored in samples. Each sample is assumed to be 50 milliseconds apart (i.e. first sample is at 0.00 seconds, second sample is at 0.05 seconds, etc).

An example session reading out flight from slot 5 would look something like this:

Code:
[09/03/2021 20:51:08] Written data (COM5)
    0d 0d 0d 0d 0d 0d 0d 0d 0d 0d 0d 0d 0d 0d 0d 0d   ................
    0d                                                .               
[09/03/2021 20:51:09] Read data (COM5)
    2a                                                *               
[09/03/2021 20:51:09] Written data (COM5)
    69                                                i               
[09/03/2021 20:51:09] Read data (COM5)
    03 10                                             ..               
[09/03/2021 20:51:09] Written data (COM5)
    0d 0d                                             ..               
[09/03/2021 20:51:09] Read data (COM5)
    2a                                                *               
[09/03/2021 20:51:09] Written data (COM5)
    66                                                f               
[09/03/2021 20:51:10] Read data (COM5)
    00 06                                             ..               
[09/03/2021 20:51:10] Written data (COM5)
    0d 0d                                             ..               
[09/03/2021 20:51:10] Read data (COM5)
    2a                                                *               
[09/03/2021 20:51:10] Written data (COM5)
    67                                                g               
[09/03/2021 20:51:10] Read data (COM5)
    06                                                .               
[09/03/2021 20:51:10] Written data (COM5)
    0d 0d                                             ..               
[09/03/2021 20:51:10] Read data (COM5)
    2a                                                *               
[09/03/2021 20:51:10] Written data (COM5)
    73                                                s               
[09/03/2021 20:51:10] Read data (COM5)
    01 23                                             ..               
[09/03/2021 20:51:17] Written data (COM5)
    0d 0d                                             ..               
[09/03/2021 20:51:17] Read data (COM5)
    2a                                                *               
[09/03/2021 20:51:17] Written data (COM5)
    61 05                                             a.               
[09/03/2021 20:51:17] Read data (COM5)
    00 04 12                                          ...             
[09/03/2021 20:51:17] Written data (COM5)
    0d 0d                                             ..               
[09/03/2021 20:51:17] Read data (COM5)
    2a                                                *               
[09/03/2021 20:51:17] Written data (COM5)
    64 05                                             d.               
[09/03/2021 20:51:17] Read data (COM5)
    02 03 02 00 01 03 00 05                           ........         
[09/03/2021 20:51:17] Written data (COM5)
    0d 0d                                             ..               
[09/03/2021 20:51:17] Read data (COM5)
    2a                                                *               
[09/03/2021 20:51:17] Written data (COM5)
    71 05                                             q.               
[09/03/2021 20:51:18] Read data (COM5)
    ff c3 04 f0 02 bc 00                              ÿÃ.ð.¼.         
[09/03/2021 20:51:18] Written data (COM5)
    64                                                d               
[09/03/2021 20:51:18] Read data (COM5)
    ff ff fc 07 17 51 00 00 01 07 17 51 00 00 02 07   ÿÿü..Q.....Q....
    16 51 00 00 01 07 17 51 00 00 06 07 16 51 00 00   .Q.....Q.....Q..
    07 07 17 51 00 00 08 07 17 51 00 00 0b 07 17 51   ...Q.....Q.....Q
[09/03/2021 20:51:18] Written data (COM5)
    64                                                d               
[09/03/2021 20:51:18] Read data (COM5)
    00 00 0d 07 17 51 00 00 12 07 16 51 00 00 15 07   .....Q.....Q....
    16 51 00 00 1a 07 17 51 00 00 1e 07 17 51 00 00   .Q.....Q.....Q..
    24 07 16 51 00 00 2a 07 17 51 00 00 30 07 17 51   $..Q..*..Q..0..Q
[09/03/2021 20:51:18] Written data (COM5)
    64                                                d               
[09/03/2021 20:51:18] Read data (COM5)
    00 00 38 07 16 51 00 00 3e 07 17 51 00 00 45 07   ..8..Q..>..Q..E.
    17 51 00 00 4c 07 17 51 00 00 56 07 17 51 00 00   .Q..L..Q..V..Q..
    5f 07 17 51 00 00 68 07 17 51 00 00 71 07 17 51   _..Q..h..Q..q..Q

... Repeat "d" commands until all 48-byte blocks of samples are read ...

[09/03/2021 20:51:20] Written data (COM5)
    64                                                d               
[09/03/2021 20:51:20] Read data (COM5)
    ff ff f2 07 18 51 ff ff f1 07 18 51 ff ff f0 07   ÿÿò..Qÿÿñ..Qÿÿð.
    18 51 ff ff f0 07 18 51 ff ff ff ff ff ff ff ff   .Qÿÿð..Qÿÿÿÿÿÿÿÿ
    ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff   ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
[09/03/2021 20:51:20] Written data (COM5)
    65                                                e               
[09/03/2021 20:51:22] Read data (COM5)
    3f                                                ?
 

Latest posts

Back
Top