Hello Guest it is January 28, 2020, 08:52:22 AM

Author Topic: Looking for Documentation LUARS232 included in Mach 4  (Read 131 times)

0 Members and 1 Guest are viewing this topic.

Looking for Documentation LUARS232 included in Mach 4
« on: November 11, 2019, 10:31:45 AM »
I have been successfully using Mach 4 and my computer's embedded serial port for some months now (using the LUARS232 module included with Mach 4). I definitely had some trouble understanding it at the beginning, but now it is a framework for serial communications with my servo drives and works great.

At the recommendation of several members and admins on this forum, I have implemented rigorous error checking and handling throughout all of my scripting. Unfortunately this has been giving me new headaches by... catching errors  ;D

I have been able to correct my code to fix all but a handful of errors, mostly thrown by calls to the serial API. Those calls do return error codes to help troubleshoot, however I have been completely unable to find documentation on the RS232 module, either within the Mach 4 documentation or on the greater internet.

For example, I have the line of code:
Code: [Select]
local err, data_read, size = p:read(4096, 100)
where 4096 is the length of buffer to be read and 100 is the timeout in ms.

This returns the error code "09", but I cannot find ANYTHING to tell me what "09" indicates or how to correct it. I am at a loss.

Any suggestions where to look would be greatly appreciated.

Thanks! - Mike
Re: Looking for Documentation LUARS232 included in Mach 4
« Reply #1 on: November 11, 2019, 11:46:52 AM »
I believe it's a time error, if I was looking at the correct source code?

https://github.com/srdgame/librs232
Re: Looking for Documentation LUARS232 included in Mach 4
« Reply #2 on: November 11, 2019, 12:33:23 PM »
jbuehn,

Thanks so much for taking the time to respond. I am not well versed in GitHub. Could you point me to where you found that information? I've been clicking through the files but have not found it yet.

-Mike
Re: Looking for Documentation LUARS232 included in Mach 4
« Reply #4 on: November 11, 2019, 02:49:25 PM »
Wow, quite burried in there. Will experiment with the timeout value tonight.

Also it seems like there is a p:flush() command which I might try instead of reading the max buffer length to empty the port.
Re: Looking for Documentation LUARS232 included in Mach 4
« Reply #5 on: November 13, 2019, 10:11:40 AM »
Making progress! Turns out the Error "09" (Timeout) will occur whenever there is not data available to be read from the buffer. This is a normal condition for me (e.g. read until the buffer is empty) so I need to adjust my error checking to not abort my script if a timeout error is generated.