View Full Version : Serial transport - receive parsing and ID'ing
December 14th, 2009, 05:41 PM
i made a basic transport that works with key digtial brand switchers. im still kind of slow with the lua so i have a few questions.
problem 1: the protocol is designed to work on a serial bus with more then one device so each device gets an id. the ID functions as the CR and prefix for the send commands. right now i have it hard coded into the transport, but this limits me to only one device. how can i fill these with a variable that can be filled in later.
problem 2: parsing the received data, the switch i am working with is a 8x4 matrix. the return comes in "UU2881" each number shows the input that the output is one 2 means output 1 is showing input 2, 8 means output 2 is showing input 8 and so on. how can i get this parsed out?
i know these are pretty basic but once i have this understanding i think i can start making these things with out questions each time.
December 14th, 2009, 06:04 PM
Can you remind me about this tomorrow - it's about time for bed so I won't be able to do this justice now.
December 14th, 2009, 06:07 PM
haha, no problem. no rush.
December 15th, 2009, 02:40 PM
i will be around the equipment in about three hours. does that work for you?
December 15th, 2009, 08:54 PM
For problem 2, parsing the received data, first store the return string in a Lua variable and then read Chapter 20 here (http://www.lua.org/pil/20.1.html). Section 20.3 (http://www.lua.org/pil/20.3.html) has examples of the captures you are after and Section 20.2 (http://www.lua.org/pil/20.2.html) explains the patterns.
Sorry I don't fully understand your problem 1. Good Luck!
December 15th, 2009, 09:59 PM
took me about 1/2 hour of rereading the same line but i got it. is this good/bad/terrible?
OnReceiveData = function(self, Event)
recv = Event:GetData()
_, _, I1, I2, I3, I4 = string.find(recv, "UU(%d)(%d)(%d)(%d)")
print(I1, I2, I3, I4)
SEND 30 32 32 38
RECEIVE 55 55 32 38 38 31 UU2881
2 8 8 1
December 16th, 2009, 09:20 AM
That all looks fine to me. Although you may want to make those local variables.
Regarding part 1, you already have a method GetSettings ie
GetSettings = function ( self )
You should be able to do what you want by changing the copied table's Parser.Terminator value to the Id of the device you want to talk to
December 16th, 2009, 04:04 PM
i see where you are going with this but i am not sure i can connect the dots.
i think that in the long run having this a full DM device is the best option. i have a full macro that i would like to run on an input switch, fade out switch fade in. at that point i could just have a drop down box in DM with 01-20 and it can be ID'ed then.
another thought would be joining the two switches in the profile, so that "input 9" (in 1 on switch 2) will automatically send the correct ID
is there a place other then the manual that can walk me through the creation of a device manager device?
December 16th, 2009, 04:33 PM
I seem to remember that someone else did a plugin and provider for a matrix switch, you could maybe search for 'matrix switch' here for the thread.
December 18th, 2009, 03:46 PM
This might help, its not DM - its the old fashioned way & a little on the clunky side but it works ok for me...
Zip file http://www.promixis.com/download.php?ID=1045
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.