SEK Command request
Odie1
Posts: 2
"Help" is a great word... some people would say aw he's not asking for help again is he... others would say ah ha it's a challenge!!!
Well this is a first for me at least. I try to solve all my problems with a large qty of reading and sometimes a small amount of dumb luck..
Using the data logger is paramont in my system... and I want to read large qty of data from it... little or no writes required...
My question is simple help me understand the "SEK" command to its fullest....
The data is contained in a file called testfile.txt that looks like this...
00001
00002
00003
00004
00005
00006
00007
etc.... to 29250
This is a comma delimited file created with this command...
SEROUT TX\CTS, Baud, [noparse][[/noparse]"WRF ", $00, $00, $00, $07, CR, DEC5 result, CR, LF, CR]
It is also created in a spreadsheet using the comma delimited TXT extention.
I understand that 7 bytes "$07" hex is the number of bytes written
then CR to end the command
then Dec5 result, CR, LF is the 7 bytes
then CR to end the command
below is a short copy of the program...
READDATA:
········· ' Open TESTFILE.TXT for (read)
DEBUG CLS
DEBUG "Opening file called TESTFILE.txt", CR
PAUSE 200
SEROUT TX\CTS, Baud, [noparse][[/noparse]"OPR testfile.txt", CR]·············· 'OPR = open for READ
GOSUB Get_Serial_Bytes
········· ' Read value into variable
PAUSE 1000
counter = 0
DO
SEROUT TX\CTS, Baud, [noparse][[/noparse]"SEK ", $00, $00, $00, Counter, CR]·············· 'SEK = goto location counter
GOSUB Get_Serial_Bytes
SEROUT TX\CTS, Baud, [noparse][[/noparse]"RDF ", $00, $00, $00, $05, CR]···················· 'RDF = READ File or setup to read 5 bytes
SERIN RX\RTS, Baud, 800, No_Data2, [noparse][[/noparse]DEC5 result]··························· ' read 5 bytes and put in result
DEBUG "Number = : ", DEC5 result," counter = ",DEC5 counter, CR········ ' Display stored value
counter = counter + 7
LOOP UNTIL (counter > 252)
········· ' Read 2nd set of Values
counter = 259
DO
SEROUT TX\CTS, Baud, [noparse][[/noparse]"SEK ", $00, $00, $01, Counter, CR]··············· 'SEK = goto location counter
GOSUB Get_Serial_Bytes
SEROUT TX\CTS, Baud, [noparse][[/noparse]"RDF ", $00, $00, $00, $05, CR]····················· 'RDF = READ File or setup to read 5 bytes
SERIN RX\RTS, Baud, 800, No_Data2, [noparse][[/noparse]DEC5 result]··························· ·' read 5 bytes and put in result
DEBUG "Number = : ", DEC5 result," counter = ",DEC5 counter, CR········· ' Display stored value
counter = counter + 7
LOOP UNTIL (counter > 511)
counter = 518
········ ' Read 3rd set of Values
DO
SEROUT TX\CTS, Baud, [noparse][[/noparse]"SEK ", $00, $00, $02, Counter, CR]··············· 'SEK = goto location counter
GOSUB Get_Serial_Bytes
SEROUT TX\CTS, Baud, [noparse][[/noparse]"RDF ", $00, $00, $00, $05, CR]···················· ·'RDF = READ File or setup to read 5 bytes
SERIN RX\RTS, Baud, 800, No_Data2, [noparse][[/noparse]DEC5 result]··························· ·' read 5 bytes and put in result
DEBUG "Number = : ", DEC5 result," counter = ",DEC5 counter, CR········· ' Display stored value
counter = counter + 7
LOOP UNTIL (counter > 763)
··········' Close TESTFILE.TXT
PAUSE 120
SEROUT TX\CTS, Baud, [noparse][[/noparse]"CLF testfile.txt", CR]
GOSUB Get_Serial_Bytes
What I need to know is how the SEK command works?
The above program works but seems cumberson to figure out all the way to 29250...
"SEK", $00, $00, $01, $FF, $05, CR would mean if I understand correctly
Goto Location 256 and read 5 bytes of info... 256 - 257 - 258 - 259 - 260
I hope this will help you understand what I need...
Thanks in advance.
Well this is a first for me at least. I try to solve all my problems with a large qty of reading and sometimes a small amount of dumb luck..
Using the data logger is paramont in my system... and I want to read large qty of data from it... little or no writes required...
My question is simple help me understand the "SEK" command to its fullest....
The data is contained in a file called testfile.txt that looks like this...
00001
00002
00003
00004
00005
00006
00007
etc.... to 29250
This is a comma delimited file created with this command...
SEROUT TX\CTS, Baud, [noparse][[/noparse]"WRF ", $00, $00, $00, $07, CR, DEC5 result, CR, LF, CR]
It is also created in a spreadsheet using the comma delimited TXT extention.
I understand that 7 bytes "$07" hex is the number of bytes written
then CR to end the command
then Dec5 result, CR, LF is the 7 bytes
then CR to end the command
below is a short copy of the program...
READDATA:
········· ' Open TESTFILE.TXT for (read)
DEBUG CLS
DEBUG "Opening file called TESTFILE.txt", CR
PAUSE 200
SEROUT TX\CTS, Baud, [noparse][[/noparse]"OPR testfile.txt", CR]·············· 'OPR = open for READ
GOSUB Get_Serial_Bytes
········· ' Read value into variable
PAUSE 1000
counter = 0
DO
SEROUT TX\CTS, Baud, [noparse][[/noparse]"SEK ", $00, $00, $00, Counter, CR]·············· 'SEK = goto location counter
GOSUB Get_Serial_Bytes
SEROUT TX\CTS, Baud, [noparse][[/noparse]"RDF ", $00, $00, $00, $05, CR]···················· 'RDF = READ File or setup to read 5 bytes
SERIN RX\RTS, Baud, 800, No_Data2, [noparse][[/noparse]DEC5 result]··························· ' read 5 bytes and put in result
DEBUG "Number = : ", DEC5 result," counter = ",DEC5 counter, CR········ ' Display stored value
counter = counter + 7
LOOP UNTIL (counter > 252)
········· ' Read 2nd set of Values
counter = 259
DO
SEROUT TX\CTS, Baud, [noparse][[/noparse]"SEK ", $00, $00, $01, Counter, CR]··············· 'SEK = goto location counter
GOSUB Get_Serial_Bytes
SEROUT TX\CTS, Baud, [noparse][[/noparse]"RDF ", $00, $00, $00, $05, CR]····················· 'RDF = READ File or setup to read 5 bytes
SERIN RX\RTS, Baud, 800, No_Data2, [noparse][[/noparse]DEC5 result]··························· ·' read 5 bytes and put in result
DEBUG "Number = : ", DEC5 result," counter = ",DEC5 counter, CR········· ' Display stored value
counter = counter + 7
LOOP UNTIL (counter > 511)
counter = 518
········ ' Read 3rd set of Values
DO
SEROUT TX\CTS, Baud, [noparse][[/noparse]"SEK ", $00, $00, $02, Counter, CR]··············· 'SEK = goto location counter
GOSUB Get_Serial_Bytes
SEROUT TX\CTS, Baud, [noparse][[/noparse]"RDF ", $00, $00, $00, $05, CR]···················· ·'RDF = READ File or setup to read 5 bytes
SERIN RX\RTS, Baud, 800, No_Data2, [noparse][[/noparse]DEC5 result]··························· ·' read 5 bytes and put in result
DEBUG "Number = : ", DEC5 result," counter = ",DEC5 counter, CR········· ' Display stored value
counter = counter + 7
LOOP UNTIL (counter > 763)
··········' Close TESTFILE.TXT
PAUSE 120
SEROUT TX\CTS, Baud, [noparse][[/noparse]"CLF testfile.txt", CR]
GOSUB Get_Serial_Bytes
What I need to know is how the SEK command works?
The above program works but seems cumberson to figure out all the way to 29250...
"SEK", $00, $00, $01, $FF, $05, CR would mean if I understand correctly
Goto Location 256 and read 5 bytes of info... 256 - 257 - 258 - 259 - 260
I hope this will help you understand what I need...
Thanks in advance.
Comments
What you showed ("SEK", $00, $00, $01, $FF, $05, CR) is not correct. It should be ("SEK",$00,$00,$01,$FF,CR) to position to byte $1FF of the currently open file (with byte 0 being the first byte). The Manual shows that the "SEK" must be followed by a 4 byte 32-bit number (MSB first), then a CR. It positions the file to the specified value. You then would have to follow that with a read command like "RDF" to actually read the data as shown in your program.
This may seem cumbersome, but it's how the Vinculum works.
Stupidity on my part for not seeing it sooner....
FOR Counter = 0 TO 1743 STEP 7
CounterA = counter/256
SEROUT TX\CTS, Baud, [noparse][[/noparse]"SEK ", $00, $00, CounterA, Counter, CR] 'SEK = goto location counter
GOSUB Get_Serial_Bytes
SEROUT TX\CTS, Baud, [noparse][[/noparse]"RDF ", $00, $00, $00, $05, CR] 'RDF = READ File or setup to read 5 bytes
SERIN RX\RTS, Baud, 800, No_Data2, [noparse][[/noparse]DEC5 result] ' read 5 bytes and put in result
DEBUG "Number = ", DEC5 result," counter = ",DEC4 counter, " CounterA = ",DEC2 counterA,CR ' Display stored value
NEXT
Worked perfect....
MSB... to LSB is the key.... for me...
Thanks again