USB Mem stick datalogger w/BS2, upgraded firmware, initialization question
xanatos
Posts: 1,120
Hi again,
I have a memory stick data logger attached to my BS2sx. I have used the Vinculum Firmware Modifier to change the startup settings to 4800, IPA, SCS and removed the "Show Version" option. The datalogger initializes fine apparently as it delivers the ">" on a power cycle. However - the program hangs whenever I attempt to write to the data logger. Here's the relevent code:
Note that the values in the write line itself are properly sized and existent (times, etc are all incoming from a DS1302 and everything worked prior to the change of the initialization.
Using DEBUGS I am able to determine that the program is hanging at the point where it is waiting for the ">" after the line to open the file:
SEROUT DLTX, DBaud,[$9, $20, "FMlog.csv", CR] ' Open file
SERIN DLRX, DBaud,[WAIT (">")]
It apparently never gives the ">" at that point. But it does in the initialization routine:
SERIN DLRX, 500,[WAIT(">")]
PAUSE 20
SEROUT LCD, LcdBaud, [LcdCls]
PAUSE 5
SEROUT LCD, LcdBaud, ["Initialized "]
Can anyone suggest what I need to do differently, now that I have firmware-changed the initialization routine, to write to the datafile on the USB stick?
Thanks very much,
Dave
PS., While much of this was covered in a 2009 thread, http://forums.parallax.com/showthread.php?114218-Datalogger-writing-requirement-question - I never actually needed this code until now. Hence this issue was never discovered until now. The 2009 project had it's parameters changed. This is a new project that is revisiting the USB Datalogger, and the need for it to power cycle to a known state, hence the firmware edit. Now I just need it to take a write again! :-)
I have a memory stick data logger attached to my BS2sx. I have used the Vinculum Firmware Modifier to change the startup settings to 4800, IPA, SCS and removed the "Show Version" option. The datalogger initializes fine apparently as it delivers the ">" on a power cycle. However - the program hangs whenever I attempt to write to the data logger. Here's the relevent code:
Init_Dlogger: SEROUT LCD, LcdBaud, [LcdCls] PAUSE 5 SEROUT LCD, LcdBaud, ["Initializing "] LOW DLTX SERIN DLRX, 500,[WAIT(">")] PAUSE 20 SEROUT LCD, LcdBaud, [LcdCls] PAUSE 5 SEROUT LCD, LcdBaud, ["Initialized "] PAUSE 400 '----[subroutines]-------------------------------------------- OPEN_WRITE_CLOSE: SEROUT DLTX, DBaud,[$9, $20, "FMlog.csv", CR] ' Open file SERIN DLRX, DBaud,[WAIT (">")] SEROUT DLTX, DBaud, [$8,$20,$0,$0,$0,$25,CR,DI, ",", TRN, ",", TRKMLG, ",", GDL, ",", HEX2 month, "/", HEX2 date, "/", HEX2 year, " ", HEX2 hrs, ":", HEX2 mins, ":", HEX2 secs,CR,$0A] ' 6th code is write size - this example, 24 (36 characters incl. CR & LFs: DI,TR#,TRKMLG,GDL,YY/MM/DD HH:MM SERIN DLRX, DBaud,[WAIT (">")] SEROUT DLTX, DBaud,[$0A, $20, "FMlog.csv", CR] ' Close file SERIN DLRX, DBaud,[WAIT (">")] RETURN
Note that the values in the write line itself are properly sized and existent (times, etc are all incoming from a DS1302 and everything worked prior to the change of the initialization.
Using DEBUGS I am able to determine that the program is hanging at the point where it is waiting for the ">" after the line to open the file:
SEROUT DLTX, DBaud,[$9, $20, "FMlog.csv", CR] ' Open file
SERIN DLRX, DBaud,[WAIT (">")]
It apparently never gives the ">" at that point. But it does in the initialization routine:
SERIN DLRX, 500,[WAIT(">")]
PAUSE 20
SEROUT LCD, LcdBaud, [LcdCls]
PAUSE 5
SEROUT LCD, LcdBaud, ["Initialized "]
Can anyone suggest what I need to do differently, now that I have firmware-changed the initialization routine, to write to the datafile on the USB stick?
Thanks very much,
Dave
PS., While much of this was covered in a 2009 thread, http://forums.parallax.com/showthread.php?114218-Datalogger-writing-requirement-question - I never actually needed this code until now. Hence this issue was never discovered until now. The 2009 project had it's parameters changed. This is a new project that is revisiting the USB Datalogger, and the need for it to power cycle to a known state, hence the firmware edit. Now I just need it to take a write again! :-)
Comments
In the place of the code where I was waiting for ">", I replaced that line with a SERIN for a variable to see what, if anything, the datalogger was returning when I attempted to open the file for writing. The response captured is:
charHold = 66 (this is the DEC of the captured value)
charHold = $42 (HEX)
charHold = "
"BC" in short command set is an abreviation of Bad Command, your test code seems to be ok so I would say the drive is not initialized completely or the baud rate is wrong.
I ran the following with a datalogger configuration of IPA,4800 with no version report. I powered up the hardware with the thumbdrive removed from the logger, I downloaded the example and then inserted the thumbdrive. The file was written to the flash. Give it a try and see if it will complete for you.
Jeff T.
I'm actually trying to tie up several parts of the same program at once at the moment, so I may be a bit slow in coming back to one of the issues... :-)
Currently when I power up the system with the Memory Stick inserted with my code, it does at least say that it is initialized (it reports Initialized once it receives the ">" that it waits for on power up.) So if I'm getting the ">"... I guess I'm confused as to why it won't respond after that. I need to initialize the drive and have it take a write command without having to remove and re-insert the drive...
More tomorrow... thanks for your assistance so far. Let me know what ideas you may come up with regarding a stationary initialization.
Best,
Dave
So... Here's my write line:
SEROUT DLTX, DBaud, [$8,$20,$0,$0,$0,$24,CR, DEC2 DI, ",", DEC3 TRN, ",", DEC4 TRKMLG, ",", DEC3 GDL, ",", HEX2 month, "/", HEX2 date, "/", HEX2 year, " ", HEX2 hrs, ":", HEX2 mins, ":", HEX2 secs,CR,$0A]
I know these things are picky as all heck when it comes to being told the exact size of the string coming at them. As I understand it. the 6th code is write size - this example, $24 (36 characters incl. commas, spaces, CR & LFs: DI,TR#,TRKMLG,GDL,YY/MM/DD HH:MM
But it hangs on the write.
Here's what is actually being written to the datalogger:
C54,064,9768,035,10/23/11 16:50:20CL
The leading C is the CR after the $24 in front of the data string, and the trailing CL represents the CR & $0A at the end of the data string.
Now I count 36 characters. Which is $24.
But just for the heck of it, I have tried $20 through $28, with the same results. It'll open the file, but hangs on write.
Stay tuned for updates... I'm still up to my neck in it...
Dave
The configuration file I am using is named FTRFB.ftd and these are the settings
UART = 4800, 8 data bits, 1 stop bit, no parity, CTS/RTS flow control
Initialization = Input mode IPA , Command mode Short Command Set , Led's flash at power on
Firmware options = there are two boxes checked :- Show Prompt and Show Device Connects/Removals
Check that your configuration matches.
It may also be looking for an upgrade, just for a test try a PAUSE 20000 right after DEBUG "> Received", CR. A twenty second delay should be enough for the upgrade check to clear if it were present.
Jeff T.
EDIT : Our posts crossed Dave, great news, your moving forward.
SEROUT DLTX, DBaud, [$8,$20,$0,$0,$0,DEC 35,CR, DEC2 DI, ",", DEC3 TRN, ",", DEC4 TRKMLG, ",", DEC3 GDL, ",", HEX2 month, "/", HEX2 date, "/", HEX2 year, " ", HEX2 hrs, ":", HEX2 mins, ":", HEX2 secs,CR,$0A]
let me know if it makes a difference
Jeff T.
So I now have a USB stick that starts in a known state, doesn't require extensive gyrations from the operator any time a power cycle occurs or the admin guy needs to remove and copy the data on the USB stick, and that writes all my data in csv spreadsheet form.
I am a happy camper! :-)
Thanks everyone for lending me your thoughts and being willing to help on this!
Dave
Jeff T.
Dave
PS,. Just FYI - I actually tried with 16 - hangs. Won't write. 15 is good, 16 hangs. How odd is that?
I think in this case the input mode is making the difference.
With input mode set to IPA then the data size should be written as ASCII
With input mode set to IPH then the data size should be written as a HEX value
Jeff T.
Thanks,
Dave
You're right on the money! I changed the hex values to DEC values and I can write the whole line in one shot.
Thanks very much! These dataloggers do have some quirks... but slowly we're getting them all documented up here. The thing works fantastically well now - completely unattended operation, self-initializing, silent logging. Happy camper! :-)
Dave