Using Pythonscript with eg.result and Read Serial Port...

Do you have questions about writing plugins or scripts in Python? Meet the coders here.
Post Reply
sjolof
Posts: 27
Joined: Tue Aug 21, 2007 11:22 am

Using Pythonscript with eg.result and Read Serial Port...

Post by sjolof » Wed Jul 09, 2008 8:23 pm

Please help me to solve my problem.

I´m sending "!" to serial port, no problem with that, but I need to check if I get the same character "!" in return before I can send my string.

I want to send "!" maximum 5 times (100msec in between).
If I get "!" in return in less then 5 tries then I could use "Jump" - (If last action successful) and send rest of my string.

But how can I check that I get "!" in return? (read serial port - python script ?) and how to limit to maximum 5 tries?

I would be really happy in someone could help me out!!!

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

Re: Using Pythonscript with eg.result and Read Serial Port...

Post by Bitmonster » Thu Jul 10, 2008 4:28 pm

Untested:

Code: Select all

Serial = eg.plugins.Serial

for i in range(5):
    Serial.Write("!")
    # read one byte with 0.1 sec timeout
    answer = Serial.Read(1, 0.1) 
    if answer == "!":
        eg.result = True
        eg.Exit()
eg.result = False
Please post software-related questions in the forum - PMs will only be answered, if really private, thanks!

sjolof
Posts: 27
Joined: Tue Aug 21, 2007 11:22 am

Re: Using Pythonscript with eg.result and Read Serial Port...

Post by sjolof » Thu Jul 10, 2008 11:31 pm

Bitmonster: Thanks for quick reply...

Sadly it didnt work.

Got theese messages:
----------------------
Python Script
Traceback (most recent call last):
Python script "24", line 4, in <module>
Serial.Write("!")
File "C:\Program Files\EventGhost\plugins\Serial\__init__.py", line 269, in __call__
AttributeError: 'NoneType' object has no attribute 'write'
----------------------
Any idea someone ???

Thanks in advance!!!

*** Update: Seems to be working on another installation... Must check this further... I will come back with results ***

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

Re: Using Pythonscript with eg.result and Read Serial Port...

Post by Bitmonster » Fri Jul 11, 2008 1:23 pm

Please post software-related questions in the forum - PMs will only be answered, if really private, thanks!

Post Reply