Uneven results with SD card files

edited September 2024 in Cyton

(This somewhat relates to previous post https://openbci.com/forum/index.php?p=/discussion/3911/best-practices-for-handling-uneven-timestamps-from-brainflow-cyton#latest, but creating a new thread to keep things tidy, as it's a separate issue.)

I'm trying to record to micro SD on the Cyton, but getting odd results. Sometimes the file looks fine and follows the spec here (https://docs.openbci.com/Cyton/CytonSDCard/#data-logging-format). But looking at my files from the last two nights:

-rwxrwxrwx 1 graham graham 1245265920 Jan  1  2000 OBCI_0E.TXT*
-rwxrwxrwx 1 graham graham    8647680 Jan  1  2000 OBCI_10.TXT*
-rwxrwxrwx 1 graham graham 1245265920 Jan  1  2000 OBCI_11.TXT*

(Let us leave aside the obvious issue that they all have the same creation date, which makes working with them tricky.)

First there is this random tiny OBCI_10 file. My code sent a 'K' command on both nights (K == record 12 hours of data), so I would expect two files and I'm not sure where this bonus file came from. The file is filled with 0x00 bytes.

Second and more importantly, the other two files do not start with, or contain, the expected "%START AT" line. They seem to begin in media res:

$ head -n 3 OBCI_11.TXT
51,FA3AA4,000000,000000,000000,000000,000000,000000,800000,0030,0370,E020
00,000000,000000,000000,000000,000000,000000,000000,000000
00,FA45F0,000000,000000,000000,000000,000000,000000,800000

$ head -n 3 OBCI_0E.TXT
EB,11F11E,000000,000000,000000,000000,000000,000000,800000,EB70,0A00,1440
EC,11EEF8,000000,000000,000000,000000,000000,000000,800000
ED,11F18C,000000,000000,000000,000000,000000,000000,800000

I have other files where everything works fine - the file starts with "% START AT" and looks as expected. My code is pretty simple and doing the same setup every time (code is here if it helps), and I'm not sure why I'm getting different results each time.

This is a decent quality SanDisk Ultra 64 GiB card (A1, 10 class). But I have noticed that sometimes it pauses for a long when as I copy files off it, so I'm not ruling out SD card hardware problems - I've ordered a 32 GiB Sandisk Ultra replacement to try.

If it helps, my app/Brainflow log (which includes the commands I'm sending manually to the board include the 'K' to start recording) is:

[2024-09-26 21:24:40.542] [board_logger] [info] incoming json: {
    "file": "",
    "file_anc": "",
    "file_aux": "",
    "ip_address": "",
    "ip_address_anc": "",
    "ip_address_aux": "",
    "ip_port": 0,
    "ip_port_anc": 0,
    "ip_port_aux": 0,
    "ip_protocol": 0,
    "mac_address": "",
    "master_board": -100,
    "other_info": "",
    "serial_number": "",
    "serial_port": "/dev/ttyUSB0",
    "timeout": 0
}
[2024-09-26 21:24:40.542] [board_logger] [trace] Board object created 0
[2024-09-26 21:24:40.542] [board_logger] [info] opening port /dev/ttyUSB0
[2024-09-26 21:24:40.549] [board_logger] [trace] port /dev/ttyUSB0 is open
[2024-09-26 21:24:40.550] [board_logger] [trace] set port settings
[2024-09-26 21:24:40.550] [board_logger] [debug] sending v to the board
[2024-09-26 21:24:41.608] [board_logger] [debug] sending d to the board
2024-09-26 21:24:42,733 - INFO - Turning off channel 1
[2024-09-26 21:24:42.733] [board_logger] [debug] sending 1 to the board
2024-09-26 21:24:43,757 - INFO - Turning off channel 2
[2024-09-26 21:24:43.757] [board_logger] [debug] sending 2 to the board
2024-09-26 21:24:44,781 - INFO - Turning off channel 3
[2024-09-26 21:24:44.781] [board_logger] [debug] sending 3 to the board
2024-09-26 21:24:45,809 - INFO - Turning off channel 4
[2024-09-26 21:24:45.809] [board_logger] [debug] sending 4 to the board
2024-09-26 21:24:46,829 - INFO - Turning off channel 5
[2024-09-26 21:24:46.829] [board_logger] [debug] sending 5 to the board
2024-09-26 21:24:47,853 - INFO - Turning off channel 6
[2024-09-26 21:24:47.853] [board_logger] [debug] sending 6 to the board
2024-09-26 21:24:48,877 - INFO - Turning off channel 7
[2024-09-26 21:24:48.877] [board_logger] [debug] sending 7 to the board
2024-09-26 21:24:49,905 - INFO - Turning on channel 0 with !
[2024-09-26 21:24:49.905] [board_logger] [debug] sending ! to the board
2024-09-26 21:24:50,925 - INFO - Starting recording to SD
[2024-09-26 21:24:50.925] [board_logger] [debug] sending K to the board
2024-09-26 21:24:52,205 - INFO - Starting stream
[2024-09-26 21:24:52.205] [board_logger] [debug] sending b to the board
2024-09-26 21:24:52,205 - INFO - Writing to file 2024-09-26-21-24-52.brainflow.csv
[2024-09-26 21:24:52.206] [board_logger] [trace] File Streamer, file: 2024-09-26-21-24-52.brainflow.csv, mods: w

Comments

  • In OBCI_0E.TXT I found the file terminates unexpectedly just a few minutes into what should be a 12 hour recording, on line 142995:

    %SamplingFreq:
    000FA
    %Total time mS:
    <<0 byte here>>003C5C96
    %min Write time uS:
    00000146
    %max Write time uS:
    0000014C
    %Over:
    00000000
    %block, uS
    

    The file then contains 0x00 bytes afterwards.

    Interestingly, line 142995 should be 9 minutes in, while the claimed total time 0x3C5C96 is 3,955 seconds or 65 minutes.
    So I'm more confused. I've checked my code and logs, and nothing should be sending a stop command. And the Brainflow CSV file I have for that night (streamed over the dongle) seems fine.

    The next night is even less lucky. It just terminates in the middle of a line, just 3 minutes in:

    A0,F951D1,000000,000000,000000,000000,000000,000000,800000
    A1,F954D9,000000,000000,000000,000000,000000,000000,800000
    A2,F95FE1,000000,000000,000000,000000,000000,000000,800000
    A3,F9611D,000000,000000,
    

    The rest of the file is filled with 0x00 bytes.

Sign In or Register to comment.