SerialThread question

Do you have questions about writing plugins or scripts in Python? Meet the coders here.
Post Reply
m3flyin2lo
Plugin Developer
Posts: 22
Joined: Sun Nov 23, 2008 3:22 am

SerialThread question

Post by m3flyin2lo » Sun Nov 23, 2008 10:20 pm

Hey guys,

I've been working on a plug-in that can control Sony VPL front projectors using the serial interface. I will be happy to share it once it is finalized, but there is one issue I would like to resolve first.

Sony projectors use Even parity in their serial communication. My plug-in is based on the SerialThread class and I had to actually modify the SerialThread class to allow the caller to set the parity. Basically, I've added an optional parameter that defaults to No Parity, but can set Odd or Even Parity if so needed.

Since this is my first Python endeavor, I would like to first ask if I maybe missed a better way of getting the same thing accomplished. It really seemed to me that the No Parity setting is hardcoded in the SerialThread class.

I am using Eventghost 0.3.6.1486 on Vista.

Thanks!

User avatar
Bitmonster
Site Admin
Posts: 2239
Joined: Mon Feb 06, 2006 10:28 pm

Re: SerialThread question

Post by Bitmonster » Mon Nov 24, 2008 7:30 pm

I have just commited a change for eg.SerialThread, that should address this issue. Since there are currently to much changes in the trunk, I can't release a new beta. You can grab the source directly from SVN:
http://eventghost.svn.sourceforge.net/v ... lThread.py
Take a look at the Open() docstring.

The question is, if dcb.fParity must be changed to True if another parity than no parity is used and how parity errors would then be processed by the code.
Please post software-related questions in the forum - PMs will only be answered, if really private, thanks!

m3flyin2lo
Plugin Developer
Posts: 22
Joined: Sun Nov 23, 2008 3:22 am

Re: SerialThread question

Post by m3flyin2lo » Tue Nov 25, 2008 5:29 am

Thanks a lot for the quick reply.
I tried your SerialThread and it works great; surprisingly, there is no need to set the dcb.fParity, btw.

I did have to pull from SVN the eg.WinApi.Dynamic class too, since you've added some new constants there.

I can't say that I know for sure how parity errors should be handled. My guess is that the transport layer somehow throws an exception in that case, which the plugin's receiver thread should catch. At that point, a parity error message would potentially need to be sent to the other end of the serial communication.

I am attaching my plugin, just in case anyone else will find it useful. In this first version, I've only implemented the commands and responses I found useful (discrete power, inputs, picture mode, etc.). More can be added easily.

Thanks for your help.
Attachments
__init__.py
SonyVPLSerial plugin code; deploy in a plugins\SonyVPLSerial directory.
(10.29 KiB) Downloaded 284 times

Post Reply