ricgjone Posted June 29, 2011 Report Posted June 29, 2011 Hi Thanks for a great product. Experimenting with the Lua com library. I need to write some hex values. tried this: com.write(display, "\xFE\x51") will this work? Regards RG
Pete Dowson Posted June 29, 2011 Report Posted June 29, 2011 Experimenting with the Lua com library. I need to write some hex values. tried this: com.write(display, "\xFE\x51") will this work? I don't know. It isn't to do with the com library but to do with Lua string formats. Did it work when you tried it, or did you get the string literally as typed? Without referring to the Lua references I can't say whether Lua supports \x type string exceptions or not. It does do \nnn for decimal, though. So you could use "\254\081" to get the values you wanted, or even string.char(0xfe, 0x51) which would be clearer though obviously a little less efficient because of the extra function call. Regards Pete
ricgjone Posted June 30, 2011 Author Report Posted June 30, 2011 Hi Yes I tried it and the text \xFE\x51 was printed, but I will try your suggestions and let you know. Thanks RG
ricgjone Posted March 26, 2015 Author Report Posted March 26, 2015 Hi An old thread, but now experimenting with something similar. Trying to use arduino to drive red/green gear lights with a simple lua script. Still new to lua. I use the event feature that triggers when the gear offsets are changed, what happens with regards to multi-threading? These 3 events will often trigger at nearly the same time and my concern is that the serial command sent from each event could be mingled together and be un recognised by the Arduino board? E.g left gear event write one character, then right gear starts before left gear event is finished writing. Regards Richard
Pete Dowson Posted March 26, 2015 Report Posted March 26, 2015 I use the event feature that triggers when the gear offsets are changed, what happens with regards to multi-threading? What's being multithreaded? These 3 events will often trigger at nearly the same time and my concern is that the serial command sent from each event could be mingled together and be un recognised by the Arduino board? E.g left gear event write one character, then right gear starts before left gear event is finished writing. Serial ports are serial devices. The output to them is serialised. There's no way it can "get mingled up". But in any case, surely you aren't using three separate Lua plug-ins, one for each light? You only need the one, with three events. Events can't interrupt the flow, pendng ones will queue till your processing is done. This sort of thing is actually quicker to try than worry about questioning. Haven't you tried? Pete
ricgjone Posted March 29, 2015 Author Report Posted March 29, 2015 Hi Pete, thanks, this info is exactly what I was after. "You only need the one, with three events. Events can't interrupt the flow, pendng ones will queue till your processing is done" Regards Richard
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now