Jump to content
The simFlight Network Forums

Recommended Posts

Posted

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

Posted

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

  • 3 years later...
Posted

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

Posted

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

Posted

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • 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.