Simple Serial Plugin - just to use for debugging

Pool / Spa Integration - Ain't life, and Indigo, GREAT when you can turn on the spa from the restaurant, and it's ready when you get home!
hamw
Posts: 1342
Joined: Mon Mar 31, 2008 7:45 pm

Re: Simple Serial Plugin - just to use for debugging

Post by hamw »

I shortened the timeouts so the plugin executes immediately - really useful. Now I'm trying to set a variable value and, when changed, execute a trigger to send a command to SSP. I tried modifying Jay's script above but keep getting errors.The command I'm trying to send is *cw,68,1,31
Any suggestions?

Code: Select all

simpleSerialId = indigo.server.getPlugin("org.yergeyjDoesntHaveaURL.simpleserial")
if simpleSerialId.isEnabled():
   message = (indigo.variable["direct_Vaux_Send"].value) 
   simpleSerialId.executeAction("textToSerial", deviceId=775789076, props={"newCommand":message})


also tried this:

simpleSerialId = indigo.server.getPlugin("org.yergeyjDoesntHaveaURL.simpleserial")
if simpleSerialId.isEnabled():
   message = "%s\n" % (indigo.variable["direct_Vaux_Send"].value) 
   simpleSerialId.executeAction("textToSerial", deviceId=775789076, props={"newCommand":message})

Error messages:
for the first trial:
Script Error embedded script: 'VariableCmds' object is unsubscriptable
Script Error Exception Traceback (most recent call shown last):

embedded script, line 3, at top level
TypeError: 'VariableCmds' object is unsubscriptable


for the second:
Script Error around line 3 - "message = "%\n" % (indigo.variable["direct_Vaux_Send"].value)simpleSerialId.executeAction("textToSerial", deviceId=775789076, props={"newCommand":message})"

Thanks!
User avatar
jay (support)
Site Admin
Posts: 19232
Joined: Wed Mar 19, 2008 11:52 am
Location: Austin, Texas
Contact:

Re: Simple Serial Plugin - just to use for debugging

Post by jay (support) »

To get a variable, use indigo.variables[ID] (not it's variables not variable):

Code: Select all

simpleSerialId = indigo.server.getPlugin("org.yergeyjDoesntHaveaURL.simpleserial")
if simpleSerialId.isEnabled():
   message = (indigo.variables["direct_Vaux_Send"].value) 
   simpleSerialId.executeAction("textToSerial", deviceId=775789076, props={"newCommand":message})
And I HIGHLY recommend using the ID rather than the name so that if the name changes the script will continue to work...
Jay (Indigo Support)
Twitter | Facebook | LinkedIn
hamw
Posts: 1342
Joined: Mon Mar 31, 2008 7:45 pm

Re: Simple Serial Plugin - just to use for debugging

Post by hamw »

All working great. Thanks again for a super plugin!
mat
Posts: 776
Joined: Thu Nov 25, 2010 10:48 am
Location: Cambridgeshire - UK

Re: Simple Serial Plugin - just to use for debugging

Post by mat »

I've email my version, with all of the timeouts removed and responce code removed.

My alterations to the plugin ignore any timings or responses thus making it fast, but not necessarily useful for everyone. I need no feedback from the port. The dmx controller that I'm using accepts commands faster than the "unrestricted" pluging can send data and have never noticed it missing a command yet.

I only use hex to save a couple of nanoseconds (I guess) to speed up further, so started removing some of the other code too, but I've not fully cleaned it up as I suspect there a very few people with the same dmx controller as me, and even fewer that want to use indigo to control it.

Cheers

Mat
Late 2018 mini 10.14
User avatar
Korey
Posts: 888
Joined: Wed Jun 04, 2008 11:47 am
Location: Henderson, NV
Contact:

Re: Simple Serial Plugin - just to use for debugging

Post by Korey »

Any progress on having multiple devices (ports) available in Indigo?

Hoping to use a 4 port Keyspan USA49WG. for RS232 control of AV components.

currently running Plugin Version 0.9.3 to control 1 device.

Thanks for a great Plugin!
Attachments
Screen Shot 2012-10-01 at 11.58.37 AM.PNG
Screen Shot 2012-10-01 at 11.58.37 AM.PNG (79.25 KiB) Viewed 19090 times
--
Korey
yergeyj
Posts: 260
Joined: Wed Dec 29, 2004 7:30 am

Re: Simple Serial Plugin - just to use for debugging

Post by yergeyj »

Korey wrote:Any progress on having multiple devices (ports) available in Indigo?

Hoping to use a 4 port Keyspan USA49WG. for RS232 control of AV components.

currently running Plugin Version 0.9.3 to control 1 device.

Thanks for a great Plugin!
Korey,

Sorry, at this juncture I do not plan to add anything additional to the Simple Serial Plugin v 0.9.3, as it was intended as just that, a "simple" plugin.

I had been doing a lot of work trying to get serial communications operating, and created this plugin just to check communications before working on a far more complicated plugin. it seemed like something worth sharing, but I really only updated it to a point that it was "operational."

Again, sorry,
Jim
4billl
Posts: 50
Joined: Wed Jan 30, 2013 10:51 am
Location: Dripping Springs TX

Re: Simple Serial Plugin - just to use for debugging

Post by 4billl »

yergeyj -
I tried using Simple Serial v0.93 with Indigo 6.0.0b5. I just installed it as a plugin and set up a DEVICE using an FTDI USB - serial convertor. Then I added a TRIGGER to get it to send. It seems to work with the lower half of ASCII (up to 127 or 0x7F) just fine, using text, decimal, or hexadecimal .
But when I tried to send anything above 0x7F using the send hexadecimal command, it either gives me an "XML Parse Error: not well-formed", or locks up Indigo 6 to the point that I have to reboot the MAC in order to restart the server.
yergeyj
Posts: 260
Joined: Wed Dec 29, 2004 7:30 am

Re: Simple Serial Plugin - just to use for debugging

Post by yergeyj »

4billl wrote:yergeyj -
I tried using Simple Serial v0.93 with Indigo 6.0.0b5. I just installed it as a plugin and set up a DEVICE using an FTDI USB - serial convertor. Then I added a TRIGGER to get it to send. It seems to work with the lower half of ASCII (up to 127 or 0x7F) just fine, using text, decimal, or hexadecimal .
But when I tried to send anything above 0x7F using the send hexadecimal command, it either gives me an "XML Parse Error: not well-formed", or locks up Indigo 6 to the point that I have to reboot the MAC in order to restart the server.
First, I've never tried sending any serial commands with non-ASCII characters, so I'll have to do a bit of research. I was however, able to reproduce the "XML Parse error," although in my case (running Indigo 6.0.0.b5) the command just terminated at the error.

I'll keep looking and try to get back soon.

Jim

P.S. I've released version 0.9.4 that catches and exits if decimal or hexadecimal values greater than 127 or 7F, respectively are entered, as the current code makes extensive use of character strings that cannot readily handle the use of extended ASCII characters. Sorry folks.
Ksullivan
Posts: 83
Joined: Sat Feb 22, 2014 5:02 pm

Re: Simple Serial Plugin - just to use for debugging

Post by Ksullivan »

Hi Jim
I have installed your plugin but cannot get it to work. I can get it to send a command but nothing happens. If I send the code using cool term then the amplifier responds.
I'm using Hex code as supplied by the manual.
Any help would be gratefully received.

Keith


Sent from my iPad using Tapatalk
wiery
Posts: 288
Joined: Mon Jun 02, 2008 2:52 am
Location: Ireland
Contact:

Re: Simple Serial Plugin - just to use for debugging

Post by wiery »

might be easier to do it via a bit of python code, i do that for somfy transmitter, works well for sending hex
hamw
Posts: 1342
Joined: Mon Mar 31, 2008 7:45 pm

Re: Simple Serial Plugin - just to use for debugging

Post by hamw »

can this plugin control more than one device at a time? Haven't tried, but if I ever move on AV control, serial would be useful to allow full feedback for a pre/pro etc.
Ksullivan
Posts: 83
Joined: Sat Feb 22, 2014 5:02 pm

Re: Simple Serial Plugin - just to use for debugging

Post by Ksullivan »

Hi Wiery

Still a novice so some help with the Python code would be great if you could

Keith


Sent from my iPad using Tapatalk
wiery
Posts: 288
Joined: Mon Jun 02, 2008 2:52 am
Location: Ireland
Contact:

Re: Simple Serial Plugin - just to use for debugging

Post by wiery »

hamw wrote:can this plugin control more than one device at a time? Haven't tried, but if I ever move on AV control, serial would be useful to allow full feedback for a pre/pro etc.
Not sure but probably not as you define the device parameters in the main configuration and you select the serial device.
wiery
Posts: 288
Joined: Mon Jun 02, 2008 2:52 am
Location: Ireland
Contact:

Re: Simple Serial Plugin - just to use for debugging

Post by wiery »

Ksullivan wrote:Hi Wiery

Still a novice so some help with the Python code would be great if you could

Keith


Sent from my iPad using Tapatalk

Keith, just match up your settings from cool term and you should be good to go and change the serialCommand to whatever you want. It needs to be wrapped in double quotes and each 2 characters escaped with \x as below.

# Import Python modules.
import serial
import time

# Command to send to the serial device.
serialCommand = "\x7F\xF2\xFA\x16\x69\xFA\x00\x00\x00\xFB\xFD\x05\xDC"

# Connection details for the serial port. Opens the port immediately.
ser = serial.Serial(
port='/dev/tty.usbserial-FTVQV0YG',
baudrate=4800,
timeout=0, # Increase this if timing is too low to get a response.
parity=serial.PARITY_ODD,
stopbits=serial.STOPBITS_ONE,
bytesize=serial.EIGHTBITS
)

# Write the command to the serial port
ser.write(serialCommand)

# Close the serial port.
ser.close()
Ksullivan
Posts: 83
Joined: Sat Feb 22, 2014 5:02 pm

Re: Simple Serial Plugin - just to use for debugging

Post by Ksullivan »

Thanks I'll give a try

Keith


Sent from my iPad using Tapatalk
Post Reply

Return to “Yergey's Forum”