Simple Serial Plugin - just to use for debugging
| Author |
Message |
|
jay (support)
Site Admin
Joined: Mar 19, 2008 Posts: 6662 Location: Austin, Texas
|
 Re: Simple Serial Plugin - just to use for debugging
Check the post 3 before yours... 
_________________ Jay (Indigo Support)
|
| Fri Sep 30, 2011 1:09 pm |
|
 |
|
dmeeker@mac.com
Joined: Aug 26, 2011 Posts: 73
|
 Re: Simple Serial Plugin - just to use for debugging
Got the new plugin, and set up a test, trying to send the on command to an htd.com lync controller to turn on a home audio zone.
The plugin is throwing the following error in the Indigo event log:
Traceback (most recent call last): File "plugin.py", line 250, in directJandy File "plugin.py", line 186, in queueSerialCmd <type 'exceptions.AttributeError'>: 'Plugin' object has no attribute 'commQueue'
Simple Serial Plugin Error Error in plugin execution ExecuteAction:
If you want more details on what commands I am sending (set up an action that had six steps, a different string being sent for each byte.
thanks ahead of time.
dave
|
| Fri Sep 30, 2011 8:18 pm |
|
 |
|
yergeyj
Joined: Dec 29, 2004 Posts: 239
|
 Re: Simple Serial Plugin - just to use for debugging
dmeeker@mac.com wrote:Got the new plugin, and set up a test, trying to send the on command to an htd.com lync controller to turn on a home audio zone.
The plugin is throwing the following error in the Indigo event log:
Traceback (most recent call last): File "plugin.py", line 250, in directJandy File "plugin.py", line 186, in queueSerialCmd <type 'exceptions.AttributeError'>: 'Plugin' object has no attribute 'commQueue'
Simple Serial Plugin Error Error in plugin execution ExecuteAction:
If you want more details on what commands I am sending (set up an action that had six steps, a different string being sent for each byte.
thanks ahead of time.
dave
Dave, I believe you may have an earlier version loaded, and unfortunately one between 0.5.0 and the current 0.7.0 version, that I mistakenly sent you on Thursday. You need to make sure you only have one version installed by restarting the Indigo server after placing the 0.7.0 version I sent last night into the Plugins (Disabled) folder. You will then need to either recreate your device, or at a minimum you will need to Edit Device Settings and set the new serial settings (baud rate, etc.). Sorry for any confusion with sending a faulty version on Thursday. I was trying to make changes to allow multiple devices, and had poor "version control" on what I sent out to you. Jim
|
| Sat Oct 01, 2011 6:00 am |
|
 |
|
dmeeker@mac.com
Joined: Aug 26, 2011 Posts: 73
|
 Re: Simple Serial Plugin - just to use for debugging
Got it working with no errors. Thank you! Now if i can figure out what to send over the port to make it work 
|
| Sat Oct 01, 2011 10:25 am |
|
 |
|
dfiedler
Joined: Mar 19, 2006 Posts: 56
|
 Re: Simple Serial Plugin - just to use for debugging
Wish List - Generic Serial PluginI am away from my system until November. I have Serial Bridge interfacing with a "LiteTouch" controller. http://www.litetouch.com/I have output strings delimitated by a CR sent to the "LiteTouch" controller over a USB Serial interface and I recieve text strings from the "LiteTouch" controller delimitated by a CR which contain information on switch presses in the house. So I am looking for a generic plugin that is listening on the serial port and when it gets a text string followed by a CR it triggers an event passing the string to a variable. It becomes the users responsibility to parse the string and trigger indigo events. This same plugin when used as an output will write an output string with a CR to the serial port. From what I see here the output part is being addressed. I need the plugin to reliably read the string from the Serial Port and trigger the script that will parse the string and cause indigo events to happen. It would seem that strings being read by the plugin must be buffered and then processed. In my environment I do not expect simultaneous events nor more than two strings in a 5 second period. But for a generic plugin I would thing more strings must be handled. Thanks. Richard
|
| Tue Oct 04, 2011 3:28 am |
|
 |
|
yergeyj
Joined: Dec 29, 2004 Posts: 239
|
 Re: Simple Serial Plugin - just to use for debugging
dfiedler wrote:Wish List - Generic Serial PluginI am away from my system until November. I have Serial Bridge interfacing with a "LiteTouch" controller. http://www.litetouch.com/I have output strings delimitated by a CR sent to the "LiteTouch" controller over a USB Serial interface and I recieve text strings from the "LiteTouch" controller delimitated by a CR which contain information on switch presses in the house. So I am looking for a generic plugin that is listening on the serial port and when it gets a text string followed by a CR it triggers an event passing the string to a variable. It becomes the users responsibility to parse the string and trigger indigo events. This same plugin when used as an output will write an output string with a CR to the serial port. From what I see here the output part is being addressed. I need the plugin to reliably read the string from the Serial Port and trigger the script that will parse the string and cause indigo events to happen. It would seem that strings being read by the plugin must be buffered and then processed. In my environment I do not expect simultaneous events nor more than two strings in a 5 second period. But for a generic plugin I would thing more strings must be handled. Thanks. Richard
Richard, This plugin "should" meet your needs. I've been using it as the basis for an interface to the Jandy pool/spa plugin, and in that roll it "listens" continuously to the serial port for messages coming from the pool system. Essentially, after establishing the serial connection it cycles through a "read, send, wait" cycle, where it reads anything sitting in the serial buffer, then sends any commands that have been queued, then waits a bit so that it doesn't cycle too frequently. If you'd like to try it, drop me a PM, and I will forward you a copy by e-mail. Jim
|
| Wed Oct 05, 2011 6:56 pm |
|
 |
|
dfiedler
Joined: Mar 19, 2006 Posts: 56
|
 Re: Simple Serial Plugin - just to use for debugging
Just started to work with your Plugin. Pardon me for being slow but I added the plugin to my devices but when I went to triggers to try to get a line of text sent over the serial line I could not seem to get the trigger to give me one.
How do I read a line of text?
Thanks
|
| Thu Nov 17, 2011 10:55 am |
|
 |
|
yergeyj
Joined: Dec 29, 2004 Posts: 239
|
 Re: Simple Serial Plugin - just to use for debugging
dfiedler wrote:Just started to work with your Plugin. Pardon me for being slow but I added the plugin to my devices but when I went to triggers to try to get a line of text sent over the serial line I could not seem to get the trigger to give me one.
How do I read a line of text?
Thanks
Richard, Not sure what is not working for you, but I suspect it's that this is really a "simple" serial plugin, that is, it is not intended to be a full featured replacement for Serial Bridge or SerialX. Because it does not create any states, it does not have anything from which to trigger. You can create an action that sends a serial command, and the response from the device will be posted to the event log, but that's it. It will also log any unsolicited communication from the serial device, for example, ongoing communication from a pool system. It's really just intended to be used to establish a serial connection for testing, and for sending commands via python, per the instructions posted. I "could" add a state that contains the most recent response from the device, but I'm not sure that would be useful. Because the serial device could be sending one-way communication, again as in the example of a pool system, the response could contain information that is in addition to any response to a command sent, and as such would be confusing to interpret. I think the best case, unfortunately, would be for use to use this plugin as a template that would allow you to set up the send-receive-decode set of information that is relevant for your particular serial device. The part of th code that deals with handling any responses is the "def decodeResponse" section, which is currently only logging any responses to the Indigo event log. Sorry, and hope this answers your question? Jim
|
| Tue Nov 22, 2011 1:21 pm |
|
 |
|
dfiedler
Joined: Mar 19, 2006 Posts: 56
|
 Re: Simple Serial Plugin - just to use for debugging
Thanks for the reply.
Your plugin does half of the job. It sends out characters to a device.
I need that too. But what I also need is that when this device sends some characters back they will be put into a variable instead of the log.
I am not worrying about buffering. When another string gets sent it overwrites the first.
Thanks
|
| Tue Nov 22, 2011 4:12 pm |
|
 |
|
yergeyj
Joined: Dec 29, 2004 Posts: 239
|
 Re: Simple Serial Plugin - just to use for debugging
dfiedler wrote:Thanks for the reply.
Your plugin does half of the job. It sends out characters to a device.
I need that too. But what I also need is that when this device sends some characters back they will be put into a variable instead of the log.
I am not worrying about buffering. When another string gets sent it overwrites the first.
Thanks
I did not add any decoding or other response-from-serial handling, as everyone has their own serial device, with different possible response possibilities, for example, ongoing two-way communication or send-receive only. That said, you can update the response from your serial port to an Indigo variable every time a response is received, by modifying the last section of the serialdevice.py file: - Code: Select all
### Log response - this plugin does not parse or do anything with the response, but it's still called decodeResponse. ### May have more than one item in response string, even if sending command def decodeResponse(self, devId, responseString, commDirection): stringLen = len(responseString) indigo.server.log("Response from serial device: " + responseString + ", of length " + str(stringLen) + " characters") ## Just add the following line to have the response update "your" Indigo variable. indigo.variable.updateValue("YourVar", responseString)
Hope this helps, Jim
|
| Wed Nov 23, 2011 11:23 am |
|
 |
|
dmeeker@mac.com
Joined: Aug 26, 2011 Posts: 73
|
 Looking for some help related to sending RS232 commands
If any of you feel like doing something extra nice this Thanksgiving holiday, I'd be quite thankful  For some additional context, here are a couple of associated files that go along with this post: http://davemeeker.com/RS232LyncControllers.pdfdavemeeker.com/C_Code.pdf I have about zero experience working with serial devices. I am using the plugin (awesome job by the way), and am trying to send commands to a home audio multi-zone controller (lync 6) from the folks at HTD.com. I have tried just about every combination that I can think of. The software that comes with the app is windows only and relies on a full GUI they provide. It is not scriptable, nor does it have any sort of API. When using the PC software, I can control the multi-zone amp like a charm. It works really well. that doesn't help me much though... I have a USB/Serial cable plugged in from the Mac that runs Indigo to the device. I am using the plugin, and have set the device I created up with all of the right settings: Baud rate: 38400 Data Bit 8 Stop Bit 1 Parity None Flow Control No The (terrible) documentation that I finally managed to get out of a support guy at HTD tells me what I should be doing to send serial commands. They call this an SDK. I call it pretty bad PDF documentation. Aside from me griping, here are two examples of what it says to perform a couple of basic function. If I can get these to work, and understand what i happen to be doing wrong, I am sure more advanced things should be pretty easy, if I follow the same basic process. 1: Query a Zone Name - This command should provide the "friendly name" I have created using the PC software for one of the audio zones. Query Zone NameHead(1 byte): 0x02 Reserved Byte(1 byte): 0x00 Zone Address(1 byte): 1-6 Command(1 byte): 0x0D Data (1 byte):0x00 so, an example would be to query Zone1 Status: 0x02 + 0x00 + 0x01 + 0x0D + 0x00 + Checksum The Checksum, the docs tell me, is each item totaled up. So the actual string is: 0x02 + 0x00 + 0x01 + 0x0C + 0x01 + 0x10 And it should return the Zone Name (in this case for Zone 1) When I execute this, here i what I see in the Indigo log: Action Group Test - Query Zone Name Full String Simple Serial Plugin Debug Queue has 1 command(s) waiting. Simple Serial Plugin Debug Processing command: 0x020x000x010x0C0x010x10
Simple Serial Plugin Debug Sending command:0x020x000x010x0C0x010x10 . Simple Serial Plugin Response from serial device: , of length 0 characters Simple Serial Plugin Debug 0x020x000x010x0C0x010x10 command completed. If I send each byte one at a time (which seems wrong to me), I see the following in the logs: Nov 24, 2011 12:57:53 PM Action Group Test - Query Zone Name Simple Serial Plugin Debug Queue has 6 command(s) waiting. Simple Serial Plugin Debug Processing command: 0x02
Simple Serial Plugin Debug Sending command:0x02 . Simple Serial Plugin Response from serial device: , of length 0 characters Simple Serial Plugin Debug 0x02 command completed. Simple Serial Plugin Debug Queue has 5 command(s) waiting. Simple Serial Plugin Debug Processing command: 0x00
Simple Serial Plugin Debug Sending command:0x00 . Simple Serial Plugin Response from serial device: , of length 0 characters Simple Serial Plugin Debug 0x00 command completed. Simple Serial Plugin Debug Queue has 4 command(s) waiting. Simple Serial Plugin Debug Processing command: 0x01
Simple Serial Plugin Debug Sending command:0x01 . Simple Serial Plugin Response from serial device: , of length 0 characters Simple Serial Plugin Debug 0x01 command completed. Simple Serial Plugin Debug Queue has 3 command(s) waiting. Simple Serial Plugin Debug Processing command: 0x0C
Simple Serial Plugin Debug Sending command:0x0C . Simple Serial Plugin Response from serial device: , of length 0 characters Simple Serial Plugin Debug 0x0C command completed. Simple Serial Plugin Debug Queue has 2 command(s) waiting. Simple Serial Plugin Debug Processing command: 0x01
Simple Serial Plugin Debug Sending command:0x01 . Simple Serial Plugin Response from serial device: , of length 0 characters Simple Serial Plugin Debug 0x01 command completed. Simple Serial Plugin Debug Queue has 1 command(s) waiting. Simple Serial Plugin Debug Processing command: 0x10
Simple Serial Plugin Debug Sending command:0x10 . Simple Serial Plugin Response from serial device: , of length 0 characters Simple Serial Plugin Debug 0x10 command completed.
So, here is what I am curious to know if you guys have any input on:
1) What am I doing incorrectly? 2) The Amp never seems to send any type of response, thoughts? 3) Am I formulating these strings properly? If anyone wants to REALLY be helpful, I have also attached the full PDF of commands to this. Maybe you can look at it and see if you have any input. I am desperate to make this work, and have pretty much exhausted anything I can think of. Thank you so so so much. Happy Thanksgiving! Dave
|
| Thu Nov 24, 2011 1:09 pm |
|
 |
|
yergeyj
Joined: Dec 29, 2004 Posts: 239
|
 Re: Simple Serial Plugin - just to use for debugging
dmeeker@mac.com wrote:...
Query Zone Name
Head(1 byte): 0x02 Reserved Byte(1 byte): 0x00 Zone Address(1 byte): 1-6 Command(1 byte): 0x0D Data (1 byte):0x00
so, an example would be to query Zone1 Status:
0x02 + 0x00 + 0x01 + 0x0D + 0x00 + Checksum
The Checksum, the docs tell me, is each item totaled up.
So the actual string is:
0x02 + 0x00 + 0x01 + 0x0C + 0x01 + 0x10
And it should return the Zone Name (in this case for Zone 1)
...
Thank you so so so much. Happy Thanksgiving! Dave
Dave, I believe your problem is interpretation of the coding. The "0x02" is one byte of information, i.e. a single character; what you are sending for this is 4 bytes/characters. I've never used this notation myself, but recognize it from the EasyDAQ plugin, and see in the PDF that the first "header byte" is 0x02. A quick look turned up the following reference to this type of hexadecimal notation: http://www.learn-c.com/data_lines.htmJim
|
| Thu Nov 24, 2011 7:06 pm |
|
 |
|
yergeyj
Joined: Dec 29, 2004 Posts: 239
|
 Re: Simple Serial Plugin - just to use for debugging
Dave,
Based on my read of the EasyDAQ plugin, and the table referenced above, I think the command you want send to encode:
0x02 + 0x00 + 0x01 + 0x0C + 0x01 + 0x10
is:
\x02\x00\x01\x0c\x01\x10
Let me know if this works, Jim
|
| Thu Nov 24, 2011 10:04 pm |
|
 |
|
dmeeker@mac.com
Joined: Aug 26, 2011 Posts: 73
|
 Re: Simple Serial Plugin - just to use for debugging
Jim, Thanks for the quick response. So, in the text box where I designate what string to send over the port, I am typing: \x02\x00\x01\x0c\x01\x10 Did you mean that? (one single command) Or do you intend the \ to be line breaks? In any case, when I send this over the port, my log shows: Nov 25, 2011 8:53:45 AM Action Group Test - Query Zone Name copy Simple Serial Plugin Debug Queue has 1 command(s) waiting. Simple Serial Plugin Debug Processing command: \x02\x00\x01\x0c\x01\x10
Simple Serial Plugin Debug Sending command:\x02\x00\x01\x0c\x01\x10 . Simple Serial Plugin Response from serial device: , of length 0 characters Simple Serial Plugin Debug \x02\x00\x01\x0c\x01\x10 command completed.
|
| Fri Nov 25, 2011 8:56 am |
|
 |
|
yergeyj
Joined: Dec 29, 2004 Posts: 239
|
 Re: Simple Serial Plugin - just to use for debugging
dmeeker@mac.com wrote:Jim, Thanks for the quick response. So, in the text box where I designate what string to send over the port, I am typing: \x02\x00\x01\x0c\x01\x10 Did you mean that? (one single command) Or do you intend the \ to be line breaks? In any case, when I send this over the port, my log shows: Nov 25, 2011 8:53:45 AM Action Group Test - Query Zone Name copy Simple Serial Plugin Debug Queue has 1 command(s) waiting. Simple Serial Plugin Debug Processing command: \x02\x00\x01\x0c\x01\x10
Simple Serial Plugin Debug Sending command:\x02\x00\x01\x0c\x01\x10 . Simple Serial Plugin Response from serial device: , of length 0 characters Simple Serial Plugin Debug \x02\x00\x01\x0c\x01\x10 command completed.
What you sent is what I meant, but realized afterwards that it wouldn't work either, as it's still sending 6 * 4 characters, not really sending 6 hexadecimal characters, which is what's needed. I think you (or I) may need to add some code that would recognize a string as hex and interpret send if differently than a standard text string. I'll think about it. Jim Jim
|
| Sat Nov 26, 2011 9:11 am |
|
|
Who is online |
Users browsing this forum: No registered users and 2 guests |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum
|
|