Author Topic: How to read/write variables in Byte data type?  (Read 11670 times)

support

  • Administrator
  • *****
  • Posts: 844
    • Script BASIC Open Source Project
Re: How to read/write variables in Byte data type?
« Reply #15 on: October 26, 2012, 09:55:30 AM »
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.


« Last Edit: October 26, 2012, 07:46:41 PM by support »
Script BASIC Project Manager

Fouad_msb

  • Guest
Re: How to read/write variables in Byte data type?
« Reply #16 on: October 26, 2012, 08:42:29 PM »
- 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

  • Administrator
  • *****
  • Posts: 844
    • Script BASIC Open Source Project
Re: How to read/write variables in Byte data type?
« Reply #17 on: October 26, 2012, 11:02:30 PM »
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.

Script BASIC Project Manager

Fouad_msb

  • Guest
Re: How to read/write variables in Byte data type?
« Reply #18 on: October 29, 2012, 03:15:15 PM »
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.
« Last Edit: October 29, 2012, 04:52:21 PM by Fouad_msb »

support

  • Administrator
  • *****
  • Posts: 844
    • Script BASIC Open Source Project
Re: How to read/write variables in Byte data type?
« Reply #19 on: October 29, 2012, 08:58:00 PM »
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.



Script BASIC Project Manager

Fouad_msb

  • Guest
Re: How to read/write variables in Byte data type?
« Reply #20 on: October 29, 2012, 11:33:49 PM »
Regarding the file I attached in prviouse post, to which module belongs the functions : waitevents() and setevents()?

support

  • Administrator
  • *****
  • Posts: 844
    • Script BASIC Open Source Project
Re: How to read/write variables in Byte data type?
« Reply #21 on: October 30, 2012, 09:39:59 AM »
Where did you find that code? It sort of looks like ScriptBasic. SB is telling you that you're calling functions that don't exist.

If you want to use cURL, you have to IMPORT/INCLUDE the curl.bas file first before calling any of the extension module functions.

Script BASIC Project Manager

Fouad_msb

  • Guest
Re: How to read/write variables in Byte data type?
« Reply #22 on: October 30, 2012, 07:17:37 PM »
Thanks a lot. I really appreciate your support :)

Fouad_msb

  • Guest
Re: How to read/write variables in Byte data type?
« Reply #23 on: November 11, 2012, 01:27:06 PM »
Hi
How are you?  Hope you doing well

Would you please send me the link of which scriptbasic
compiler that could be installed in android!

Thanks a lot

support

  • Administrator
  • *****
  • Posts: 844
    • Script BASIC Open Source Project
Re: How to read/write variables in Byte data type?
« Reply #24 on: November 11, 2012, 02:03:31 PM »
ScriptBasic is an interpretive scripting language written with ANSI/ISO compliant C compiler.

I have an experimental version of ScriptBasic for Android native Linux you are welcome to try. I was able to get AIR's SQLite3 extension module working on Android. (self contained with no dependencies)
« Last Edit: November 11, 2012, 05:19:58 PM by support »
Script BASIC Project Manager

Fouad_msb

  • Guest
Re: How to read/write variables in Byte data type?
« Reply #25 on: November 13, 2012, 01:46:51 PM »
Hi,

Does it need something other than unzipping and copying it!
Whenever I try to run it,  it gives an error,  file not found

support

  • Administrator
  • *****
  • Posts: 844
    • Script BASIC Open Source Project
Re: How to read/write variables in Byte data type?
« Reply #26 on: November 13, 2012, 01:58:56 PM »
Check out THIS thread and if you're still having issues, let me know.

Script BASIC Project Manager