serialControlString

Dar Scott dsc at swcp.com
Tue Nov 25 17:32:22 EST 2003


On Tuesday, November 25, 2003, at 06:34 AM, Thomas J McGrath III wrote:

> I think you guys forgot that I am way new to REV, so syntax is 
> tripping me up big time. I have been able to communicate TO the device 
> but not get any desired result from the device.
> Do I need to read from device in order to get the result or should the 
> result be a part of the write to process being returned ? I want to 
> learn more but this is way beginner stuff concerning the proper syntax 
> and expected results.

I have used the word 'result' in a particular way and there may be 
confusion.

Many commands will set an error value.  Each serial command will set an 
error value.  If all is well, it is empty.  Otherwise it is a text 
value that might be helpful.

The function result() returns that value.  An alternate syntax is 'the 
result'.

I also look at the the value returned by sysError(), which often 
returns the error code returned by the underlying system.  That might 
not be meaningful to you, but it might help those on the list who 
provide advice.

This is independent of getting the response from the device.  (I'm 
using the word "response" to avoid saying "result" which is ambiguous, 
because of the result() function.)

To get the response from the device, read from the device.  The 
characters read will be in the local variable named 'it'.  Thus, with a 
read, you can look at 'it' and 'the result'.  The first will be the 
data from the MacBrick and the second will be some status information 
about the read (not about the MacBrick).

If you think you are actually writing to the equipment, then try 
something like this after that in your script (where macBrickPort is 
defined earlier):

     wait 2 seconds
     read from driver macBrickPort until empty
     put "response = " & quote & it & quote & LF into report
     put "result (error) = " & quote & the result & quote & LF after 
report
     put "system error = " & the sysError & LF after report
     put report

Dar Scott






More information about the Use-livecode mailing list