Support > ScriptBasic Examples w/source
How to read/write variables in Byte data type?
Support:
--- Code: ---Send_Buf[0] = CHR(&H2)
Send_Buf[1] = CHR(&H6)
Send_Buf[2] = CHR(&H4)
Send_Buf[3] = CHR(&H1)
Send_Buf[4] = CHR(&H22)
Send_Buf[5] = CHR(&H10)
Send_Buf[6] = CHR(&H0)
Send_Buf[7] = CHR(&H0)
FOR i = 0 TO 6
Send_Buf[7] = Send_Buf[7] XOR Send_Buf[i]
NEXT
PRINT ASC(Send_Buf[7]),"\n"
--- End code ---
jrs@laptop:~/sb/test$ scriba mytest2.sb
48
jrs@laptop:~/sb/test$
Does your VB code return the same value as above?
The rest is simply opening up a socket and using PRINT and INPUT to communicate with the device.
Fouad_msb:
the value is 51.
I think it should be converted to decimal before XOR loop.
Support:
--- Code: ---Send_Buf[0] = &H2
Send_Buf[1] = &H6
Send_Buf[2] = &H4
Send_Buf[3] = &H1
Send_Buf[4] = &H22
Send_Buf[5] = &H10
Send_Buf[6] = &H0
Send_Buf[7] = &H0
FOR i = 0 TO 6
Send_Buf[7] = Send_Buf[7] XOR Send_Buf[i]
NEXT
PRINT Send_Buf[7],"\n"
--- End code ---
jrs@laptop:~/sb/test$ scriba mytest3.sb
51
jrs@laptop:~/sb/test$
My error, I shouldn't have converted it to a character value first. :-\
Fouad_msb:
it works fine. thanks a lot :)
I have another question, how to make a timer! without stopping the program sequence?
I tried to make a loop, but it will not go to then next step.
I need to pull the data every 3 sec, in the same time that will not affect the other commands like which need to send it to the device.
for example, I have a thermostat which need to read the temperature every 3 sec, and in the same time I can send or change the setpoint by sending a command to the device.
thanks a lot. I reall appreciate your support.
Fouad
Support:
ScriptBasic doesn't support timers like VB so you may have to be a little creative with this. You have a few ways to approach this.
1. You could create a MAIN routine that checks NOW and runs a set of SUBs/FUNCTIONs and SLEEPs when there is nothing to do.
2. Create two scripts. One that polls devices as gets info and write it to a file. The other script would process the file on a first in first out basis.
3. Create an extension module with a true timer and access your device from the extension module.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version