Support > ScriptBasic Examples w/source

How to read/write variables in Byte data type?

<< < (4/6) > >>

Support:
It's been a long time since I played with serial port communications under Windows. I think you need to setup the port from the OS (bits, speed, parity, ...) before using it in your SB script. You may be able to do this from SB with a SYSTEM command prior to opening the COMM port. You are just going to have to play with it to find out what works. I see no reason to close the port between access runs but this is something you will need to experiment with. Please keep us in the loop with your progress.

You don't have to use LINE INPUT and can use INPUT that doesn't wait for an end of line sequence. You tell INPUT how many characters to get and it will return what you requested or whatever is in the buffer at the time.


Fouad_msb:
- ok, what's the command you use to set up the COMM port (bit, speed,parity,...) under Linux?

- I used input with 8 characters/bytes, but still if one device is offline, then it will stop at that
step and will not run the rest of lines in the program!So, I would like to use the command Input with
time like 3 sec maximam so if there is no response from the device, then it just wait for 3 seconds then
goes to the next step.

- What's the command to check the port stauts if it is opened or not?


Thanks a lot, and sorry for bothering you with my many questions :)

Support:
Try a MODE command to setup your serial port.

The CURL extension module allows connecting to a port with timeout support. (and a bunch of other features) Maybe you can give that a try. SB's socket/serial port support is pretty raw.

Fouad_msb:
I included the module and added the following line:
curl::option CurlHandle,"CONNECTTIMEOUT",5

but the output was as follows:

(0): error &H72: Built in function has too few arguments

========
By the way, I downloaded the attached file which is a sample showing how to do non-blocking serial i/o. But it gives an error
(0): error &H68:The user function "waitevents" is used but is not defined.
(0): error &H68:The user function "setevent" is used but is not defined.
(0): error &H68:The user function "setevent" is used but is not defined.

Support:
ScriptBasic OPEN of sockets and serial ports do NOT support timeouts. SB will wait forever on a port until it's closed.

I didn't have much hope for serial port support with cURL but it looks like you might have discovered a way. If cURL works for serial ports, that is the best way to go.



Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version