excuseme
I want to send with serialoutblock() this command:
FFAA53030001000001
that is a number in hexadecimal (no ASCII). but is more than 4 bytes.
I thought I could
SerialOutBlock (COMRS232,&hFFAA53030001000001,9)
is it correct that way?
and the answer is more tha 4 bytes.
can you help me?
One way to go about it is to make an array. The array is sequential memory locations, and you can store 4 bytes in each element of the array.
Dim OutData(3) as Long
OutData(1) = &FFAA5303
OutData(2) = &00010000
OutData(3) = &01000000 'You have to pad the last variable with data at the end
SerialOutBlock (COMRS232,OutData(1),9)
i will try thank you
but i see you put OutData(1) = &FFAA5303 ? what about &H?
You are correct I forgot the H in &H.
thank you i made you said and I see the unit response. but how the number is very large more than 4 bytes. I put an array "Indata()".
but the answer i get in parts. and I see that they are in decimal I need hexadecimal.
probe with hyperterminal I see that sent values different to the datalogger give me. for that reason i think that they are in decimals.
how can I get all the number complete in one variable?
Public PTemp, batt_volt, instring As String * 1000, longreturn As Long
Dim OutData(3) As Long
Dim Indata (18) As Long
BeginProg
Scan (1,Sec,0,0)
SerialOpen(ComRS232,-9600,0,10,1000)
OutData(1) = &HFFAA5303
OutData(2) = &H00010000
OutData(3) = &H01000001
SerialOutBlock (COMRS232,OutData(1),12)
SerialInBlock (COMRS232,Indata (1),1000)
MoveBytes(longreturn,0,Indata(1),0,4)
CallTable Test
NextScan
EndProg
To read in more than 4 bytes, it can be more convenient to read them into a string.
As a way to see whats in the string, here is an example program that creates another string that is an ASCII representation of the Hex.
Public BinString As String
Public LongVal As Long
Public HexString As String * 64
Dim i As Long
'Main Program
BeginProg
LongVal = &h0a0b0c0d 'Loading some example data to display
MoveBytes (BinString,5,LongVal,0,4)
Scan (1,Sec,0,0)
HexString = ""
For i = 1 To 16
LongVal = ASCII(BinString(1,1,i))
HexString = HexString & FormatLong (LongVal,"%02X") & " "
Next
NextScan
EndProg
THANK YOU
BUT IS HAPPENING SOMETHING RARE....WHEN I PROBE WHIT A HYPERTERMINAL THE ANSWER IS:
HEXADECIMAL NUMBER SENT: {FF}{AA}{C0}{02}{00}{01}{00}{01}
RESPONSE: {FF}{35}{41}{00}{40}{97}{01}{0D}{36}{ED}{FF}{08}{01}{20}{FF}
BUT THE DATALOGGER REPSONSE
RESPONSE DATALOGGER: 1074790401194628838421811764066304
AND WHEN I CONVERT TO HEXADECIMAL WITH THE PROGRAM
31 30 37 34 37 39 30 34 30 31 31 39 34 36 32 38 38 33 38 34 32 31 38 31 31 37 36 34 30 36 36 33 30 34
PROGRAM:
Public HexString As String * 1000, longreturn As Long, A As String * 1000
Public BinString As String * 1000
Dim OutData(2) As Long
Dim Indata (4) As Long
Dim i As Long
BeginProg
Scan (10,Sec,0,0)
SerialOpen(ComRS232,-9600,0,10,1000)
OutData(1) = &HFFAAC002
OutData(2) = &H00010001
SerialOutBlock (COMRS232,OutData(1),8)
SerialInBlock (COMRS232,Indata (1),1000)
A=Indata(1)
A=A&Indata(2)
A=A&Indata(3)
A=A&Indata(4)
BinString=A
HexString=""
For i = 1 To 34
longreturn = ASCII(BinString(1,1,i))
HexString = HexString & FormatLong (longreturn,"%02X") & " "
Next
PanelTemp (PTemp,250)
Battery (batt_volt)
CallTable Test
NextScan
EndProg
Just use MoveBytes to directly copy the binary data from InData to BinString.
SerialInBlock (COMRS232,Indata (1),1000)
MoveBytes(BinString,0,InData,0,16)
HexString=""
For i = 1 To 34
longreturn = ASCII(BinString(1,1,i))
HexString = HexString & FormatLong (longreturn,"%02X") & " "
Next
thank you
I dont know why but when the response of the unit must to be
{FF}{35}{41}{00}{40}{97}{01}{0D}{36}{ED}{FF}{08}{01}{20}{FF} (follow the hyperterminal).
the datalogger cr1000 response:
Data (1)=1074790401
Data (2)=1946288384
Data (3)=218117640
Data (4)=66304
then join them: 1074790401194628838421811764066304.
i think that is the response from the unit that the datalogger display in decimal but when I convert to hexadecimal i get
34FDC3166D213000000000000000
and that is not the response that I am waiting.
Convert the individual pieces to hexadecimal, then put them together.