Jump to content
The simFlight Network Forums
Sign in to follow this  
ricgjone

Lua Serial port and hex

Recommended Posts

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.