USB Datalogger Get_Serial_Bytes
Hi there,
Could somebody tell me what the Get_Serial_Bytes routine for the SB data logger is actually doing please? I have looked through the firmware spec and examined the code but I'm just not sure of its purpose. I am·only going to be sending to the USB device so is it·required?
Here·is the code,
Get_Serial_Bytes:
· timeout = 1·········································· ' Set Timeout Indicator Flag
· index = 0············································· ' Initialize Index
· DO WHILE (timeout > 0)························ ·' While Timeout Has Not Occurred
··· ioByte = 0··········································' Clear Temporary Storage
··· SERIN RX\RTS, Baud, 100, No_Data, [noparse][[/noparse]ioByte]
··· buffer(index) = ioByte·························· ' Save Byte Received To Array
··· index = index + 1································ ' Increment Index
··· IF (index > 14) THEN··························· ' Check For Overflow
····· index = 14······································· ' Prevent Overflow
··· ENDIF
· LOOP
RETURN
Thanks very much
Leo
Could somebody tell me what the Get_Serial_Bytes routine for the SB data logger is actually doing please? I have looked through the firmware spec and examined the code but I'm just not sure of its purpose. I am·only going to be sending to the USB device so is it·required?
Here·is the code,
Get_Serial_Bytes:
· timeout = 1·········································· ' Set Timeout Indicator Flag
· index = 0············································· ' Initialize Index
· DO WHILE (timeout > 0)························ ·' While Timeout Has Not Occurred
··· ioByte = 0··········································' Clear Temporary Storage
··· SERIN RX\RTS, Baud, 100, No_Data, [noparse][[/noparse]ioByte]
··· buffer(index) = ioByte·························· ' Save Byte Received To Array
··· index = index + 1································ ' Increment Index
··· IF (index > 14) THEN··························· ' Check For Overflow
····· index = 14······································· ' Prevent Overflow
··· ENDIF
· LOOP
RETURN
Thanks very much
Leo
Comments
This reads reads up to 15 characters from the datalogger into a buffer and stops when either 15 characters have been received or there's a timeout because the datalogger has stopped sending (because it's finished). This is used to read the response to a command, usually some kind of status or error message from the datalogger, but it may be data followed by a status or error message.
In the version you posted, I'm not sure why there's the timeout variable without being able to see the rest of the code.
Thanks very much for that. What I posted was actually the code I took from the demo program I have. Maybe its a little out of date now.
As I am sending sets of 255 bits of data to the USB drive, and they are the same each time (i'm also certain they are error free), am I going to need the get serial byte routine? Because I dont believe I have anything to read from the drive at all. (I know in the demo code it does read from the drive)
The reason I ask is because the routine is taking up variable space that I really need for the rest of the code.
Thanks again for your help
Leo
The routine can be simplified considerably. There is no need for a 14 character buffer if you do not need to read actual data from the disk. The status/error messages in short command mode are never more than 4 bytes. The purpose of the purge is to clear the datalogger data pending buffer, and that will leave it clear so that the bytes present after the execution of your command will be right there at the top of the buffer. My own inclination is to do fairly strong error checking. I want my program to know that it is working correctly. It can be pretty frustrating to write these routines, because the Vinculum documentation is not super clear about what is going on in its firmware.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com