Memory Stick Datalogger: warning & question
xanatos
Posts: 1,120
Memory Stick Datalogger users: Beware the PNY 8 GB memory stick that is in the picture below... it works, but won't complete the write of the previous operation until the next write operation comes along!
I have several dozen of these guys (the dataloggers, not the PNY sticks) in the field working flawlessly, but I noticed that on this project, during testing, that the last operation performed before the box was powered down, opened, and the stick removed and read in a regular laptop, was consistently absent. After checking my code (which, as I said, is working perfectly in many identical copies out there), I just tried a different memory stick, and voila! Everything worked perfectly. I tried again with the PNY stick, and same thing. If I do 7 tests, I'll get data from test 1 - 6. If I do 12, I'll get 1 - 11.
So there's the warning.
The question: Since it's possible a customer in the field may use their own memory stick for this, and therefore it's possible they could use one of these or one like it, what might be happening in these? And is there something that I might want to do in my code, other than doing a bogus write after every valid write, to ensure the file gets written to the stick AND stored by the stick, after every write. According to my debug tests, the write operation and file closing are all happening properly, so it's definitely in the stick itself.
My stick-writing code is below; the datalogger is flashed with a setup to preset the baud rate etc.
I have several dozen of these guys (the dataloggers, not the PNY sticks) in the field working flawlessly, but I noticed that on this project, during testing, that the last operation performed before the box was powered down, opened, and the stick removed and read in a regular laptop, was consistently absent. After checking my code (which, as I said, is working perfectly in many identical copies out there), I just tried a different memory stick, and voila! Everything worked perfectly. I tried again with the PNY stick, and same thing. If I do 7 tests, I'll get data from test 1 - 6. If I do 12, I'll get 1 - 11.
So there's the warning.
The question: Since it's possible a customer in the field may use their own memory stick for this, and therefore it's possible they could use one of these or one like it, what might be happening in these? And is there something that I might want to do in my code, other than doing a bogus write after every valid write, to ensure the file gets written to the stick AND stored by the stick, after every write. According to my debug tests, the write operation and file closing are all happening properly, so it's definitely in the stick itself.
My stick-writing code is below; the datalogger is flashed with a setup to preset the baud rate etc.
OPEN_WRITE_CLOSE: SEROUT DLTX, DBaud,[$09, $20, "FMLOG.csv", CR] ' Open file SERIN DLRX, DBaud,[WAIT (">")] DEBUG "Open", CR IF pr = 1 THEN READ 1, DI ' Get Var values stored in EEPROM in FMS1-kbd.bpx for power-cycle data recovery READ 2, Word TRN READ 4, Word TRKMLG READ 6, Word TRKMLG2 READ 8, GDL READ 9, tenths READ 10, Word passCode SEROUT DLTX, DBaud, [$8,$20,$0,$0,$0,DEC 46,CR, DEC2 DI, ",", DEC3 TRN, ",", DEC3 TRKMLG, DEC3 TRKMLG2, ",", DEC4 passCode, ",", HEX2 month, "/", HEX2 date, "/", HEX2 year, " ", HEX2 hrs, ":", HEX2 mins, ":", HEX2 secs, ",", DEC3 GDL, ".", DEC1 tenths, " *", CR, $0A] ' 6th code is write size in DEC (with firmware set to 4800/IPA/SCS) DEBUG "Written (PR)",CR ELSE SEROUT DLTX, DBaud, [$8,$20,$0,$0,$0,DEC 44,CR, DEC2 DI, ",", DEC3 TRN, ",", DEC3 TRKMLG, DEC3 TRKMLG2, ",", DEC4 passCode, ",", HEX2 month, "/", HEX2 date, "/", HEX2 year, " ", HEX2 hrs, ":", HEX2 mins, ":", HEX2 secs, ",", DEC3 GDL, ".", DEC1 tenths, CR, $0A] ' 6th code is write size in DEC (with firmware set to 4800/IPA/SCS) DEBUG "Written",CR ENDIF SEROUT DLTX, DBaud,[$0A, $20, "FMLOG.csv", CR] ' Close file SERIN DLRX, DBaud,[WAIT (">")] DEBUG "Closed",CR WRITE 0, 0 ' Return power recovery data flag to 0. RETURN
Comments
Jeff T.
I've used these successfully with sticks as small as 1GB, and as large as 8GB. I *think* I used a 16GB unit once just as a quick test for something else. It may be that the units will not recognize memory above a certain size, but the devices certainly work for everything I've ever used them for. And since usually I'm writing datalines that are seldom in excess of 100 characters, 8GB is a LOT of datalines!