Support > ScriptBasic Examples w/source
How to read/write variables in Byte data type?
Fouad_msb:
How Can I use the serial port instead of the ethernet?
does the following command is correct? I tried it but still gives an error "(0): error &H16:The file can not be opened."
============
open "COM1:4800" for comm as 1
Support:
--- Quote ---open "COM1:4800" for comm as 1
--- End quote ---
Try this.
--- Code: ---OPEN "COM1:4800" FOR BINARY AS #1
--- End code ---
I tried the following with my old laptop running Ubuntu that has an internal modem.
--- Code: ---OPEN "/dev/ttySL0" FOR BINARY AS #1
PRINT #1,"ATZ\r"
LINE INPUT #1, mr
PRINT mr
LINE INPUT #1, mr
PRINT mr
--- End code ---
jrs@laptop:~/sb/test$ scriba testmodem.sb
ATZ
OK
jrs@laptop:~/sb/test$
Fouad_msb:
Thanks a lot, It works :)
What's the syntax for "Select Case"?
Support:
--- Quote ---What's the syntax for "Select Case"?
--- End quote ---
--- Code: ---IF case = 1 THEN
' Do case 1 stuff
ELSE IF case = 2 THEN
' Do case 2 stuff
ELSE
' Do default case stuff
END IF
--- End code ---
Sorry, no SELECT/CASE but IF/THEN/ELSE has unlimited nesting.
Fouad_msb:
ok, thanks.
1-The command you sent me "OPEN "COM1:4800" FOR BINARY AS #1" for opening the seiral port is working fine, but sometimes it doesn't read till I use a serial port monitor software, then after closing it , it can work in script basic! I guess need to specify the Data Bits, Parity & Stop Bits. So, would you please help me how to specify these data for the com port!
2- I need to read the temperature every 3 Seconds, and in that I open the port & close it again. So, how can I check if the port (Ethernet + Com port) is already opened to avoid opening it again and avoid errors?.
3- What's your suggestion when need to read the temperature or any data in such small period, shall I keep the port open or just open it then close it at the end of the function?
4- How to make the line input (waiting to receive the reply from the device or port" specified with a time? so, that step will not stop the process for long and doesn't affect the next step of the sequence. For example if I'm pulling data from 3 devices and if the first one is offline, than it will stop reading data from other devices.
Thanks a lot
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version