Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details

If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.

Serial Port Plugin

If you have a question or need help, this is the place to be.
Post Reply
dyingstar
Posts: 1
Joined: Tue Jul 31, 2007 2:35 am

Serial Port Plugin

Post by dyingstar »

Hey Guys,

I'm curious as to how the serial.write() function outputs the data. I am trying to output bytes of data. Should I use decimal, hexademical, binary notation, or something else? Is there a way I can send exactly one byte? I am a beginner when it comes to programming, so I apologize if this question has already been answered in the documentation. I looked, but I couldn't find it.

Thanks.
sdx
Posts: 19
Joined: Sat May 12, 2007 9:40 am

Re: Serial Port Plugin

Post by sdx »

I have the same question:

I have to send hexadecimal value to serial port , what is the format to be used ?
User avatar
Bitmonster
Site Admin
Posts: 2239
Joined: Mon Feb 06, 2006 10:28 pm

Re: Serial Port Plugin

Post by Bitmonster »

Get the beta and read the help to the actions.
Please post software-related questions in the forum - PMs will only be answered, if really private, thanks!
sdx
Posts: 19
Joined: Sat May 12, 2007 9:40 am

Re: Serial Port Plugin

Post by sdx »

Thanks, the send action is working OK.

2 things I do not unerstand :

1 => How to use "Generate events on incoming data", I have selected the box but no envent appear

2 => How to use the read function, my device send me 17 bytes hexadecimal return information, I would like to read it. I have tried both "Read as many bytes as currently available" and "Read exactly this maximum number of bytes" = 17 , "for" 2000 ms and nothing happens. (I use another soft : "advanced serial port monitor" and I see the information that should be read, so my device answers)
PeteThornbury
Posts: 3
Joined: Tue Sep 04, 2007 6:31 pm

Re: Serial Port Plugin

Post by PeteThornbury »

From the Beta:

"Writes some text through the serial port.
You can use Python string escapes to send non-printable characters. Some examples:
\n will send a Linefeed (LF)
\r will send a Carriage Return (CR)
\t will send a Horizontal Tab (TAB)
\x0B will send the ASCII character with the hexcode 0B
\\ will send a single Backslash."
sdx
Posts: 19
Joined: Sat May 12, 2007 9:40 am

Re: Serial Port Plugin

Post by sdx »

Sorry but as indicated in my last post, I am able to send data "SERIAL PORT : WRITE DATA" is working OK

I have issues with reading data on serial port either using the "SERIAL PORT : READ DATA" action or expecting an event.
PeteThornbury
Posts: 3
Joined: Tue Sep 04, 2007 6:31 pm

Re: Serial Port Plugin

Post by PeteThornbury »

Does your device terminate all of it's transmissions with a specific character? If so, make sure that character is listed in the "terminator" field under the serial port plugin configuration. You may use the same python string escapes here as you can in the send event. (eg \x80 for hex 80) As for the read data, your guess is as good as mine as to where exactly that data goes after it has been read...

On a related note:
The problem I am currently having is trying to control my crystalfontz lcd panel using the serial plugin and the crystalfontz lcd panel terminates with a CRC, so it is different every time. Not only can I not input a termination character, it is also very hard for me to send data to the lcd because I need to figure out the crc for any message I send. Anyone have any suggestions? Is there a plugin for controlling LCDs?
sdx
Posts: 19
Joined: Sat May 12, 2007 9:40 am

Re: Serial Port Plugin

Post by sdx »

I have tried what this, the information sent by the device is hexedecimal and finishes with \xFF.
So I indicated this character as terminator.

This creats an bug:

10:00:59 Exception in thread Thread-6:
10:00:59 Traceback (most recent call last):
10:00:59 File "threading.pyc", line 460, in __bootstrap
10:00:59 File "threading.pyc", line 440, in run
10:00:59 File "C:\Program Files\EventGhost 3.6\plugins\Serial\__init__.py", line 180, in ReceiveThread
10:00:59 File "C:\Program Files\EventGhost 3.6\plugins\Serial\__init__.py", line 134, in HandleChar
10:00:59 File "C:\Program Files\EventGhost 3.6\eg\RawReceiverPlugin.py", line 58, in TriggerEvent
10:00:59 File "C:\Program Files\EventGhost 3.6\eg\PluginClass.py", line 140, in TriggerEnduringEvent
10:00:59 File "C:\Program Files\EventGhost 3.6\eg\EventThread.py", line 73, in TriggerEnduringEvent
10:00:59 File "C:\Program Files\EventGhost 3.6\eg\EventGhostEvent.py", line 45, in __init__
10:00:59 UnicodeDecodeError: 'ascii' codec can't decode byte 0xfc in position 0: ordinal not in range(128)

The hexadecimal chain to be received is like :

\xFC\x32\x11\x05\x00\x01\x02\x00\x00\x26\x22\x01\x00\x00\x30\x39\xFF
User avatar
Bitmonster
Site Admin
Posts: 2239
Joined: Mon Feb 06, 2006 10:28 pm

Re: Serial Port Plugin

Post by Bitmonster »

I have not much time these days. So in short:

First:
Serial.Read returns the data through eg.result, as any action does that is returning data. So you have to use Python scripting to do anything with it:
http://www.eventghost.org/wiki/Scripting
Serial.Read and event generation cannot be used at the same time, as one of it will always eat the data away from the other.

The Unicode error:
This will be fixed betimes. The problem is, that the plugin doesn't know what encoding you want to use. It currently assumes ASCII but I will add an option for Hex, UTF8/16, Latin-1 and so on.

Using Serial.Write with a CRC:
Again this will only be possible with some scripting. You have to calculate the CRC yourself and can then use eg.plugins.Serial.Write(myString) from your script.
Please post software-related questions in the forum - PMs will only be answered, if really private, thanks!
User avatar
Pako
Plugin Developer
Posts: 2294
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: Serial Port Plugin

Post by Pako »

sdx wrote:
The hexadecimal chain to be received is like :

\xFC\x32\x11\x05\x00\x01\x02\x00\x00\x26\x22\x01\x00\x00\x30\x39\xFF
You can try the attached serial plugin and port settings (item Terminator).
Pako
Attachments
Serial port settings.png
__init__.py
(12.95 KiB) Downloaded 443 times
User avatar
Bitmonster
Site Admin
Posts: 2239
Joined: Mon Feb 06, 2006 10:28 pm

Re: Serial Port Plugin

Post by Bitmonster »

The latest beta includes a new option to set the encoding with "generate events". If you set this option to "HEX" you will get an event string like
Serial.FC3211050001
if you receive raw byte code data like:
\xFC\x32\x11\x05\x00\x01

Another option for these circumstances is "Python string escape" that will output every ascii character as ascii character, but replaces every non printable characters with a string escape like "\xff".
Please post software-related questions in the forum - PMs will only be answered, if really private, thanks!
stefstef
Posts: 4
Joined: Fri Sep 07, 2007 8:23 am

Re: Serial Port Plugin

Post by stefstef »

Is it possible to have the same behaviour as http://www.winamp.com/plugins/details/92855 with serial port plugin.

For example, you can go to http://www.instructables.com/id/EQ4DKO0H01ERIE2AAM/

EventGhost is a wonderful.
User avatar
Bitmonster
Site Admin
Posts: 2239
Joined: Mon Feb 06, 2006 10:28 pm

Re: Serial Port Plugin

Post by Bitmonster »

stefstef wrote:Is it possible to have the same behaviour as http://www.winamp.com/plugins/details/92855 with serial port plugin.

For example, you can go to http://www.instructables.com/id/EQ4DKO0H01ERIE2AAM/

EventGhost is a wonderful.
Currently not. It would need some hours of coding and I'm actually not motivated to do it. There is also a problem with the RING indicator line of such devices. Windows only detects the rising edge of the signal efficiently, so the falling edge has to be detected by polling and this impacts system performance.

If you want some buttons that you can wire anywhere, get a cheap USB gamepad with many buttons from the rummage table, dismantle it and solder some cables to the circuit board. Then you have a really nice USB device, that works perfectly with EG's Joystick plugin.
Please post software-related questions in the forum - PMs will only be answered, if really private, thanks!
stefstef
Posts: 4
Joined: Fri Sep 07, 2007 8:23 am

Re: Serial Port Plugin

Post by stefstef »

It's very good idea, thanks !
Post Reply