Skip to content

Commit

Permalink
Added support for Linux in the SerialCom.py connection function
Browse files Browse the repository at this point in the history
The connect would previously only work immediately preceding a download
(on Debian Jessie). This was solved by connecting first with rtscts
enabled, which triggers something to allow messages to be received.
I think the board is being reset on each connection, this is a workaround.
  • Loading branch information
seken committed Jun 15, 2015
1 parent 9d1398f commit a92a327
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion mDrawGui/SerialCom.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import serial
import platform
import threading
import time
import platform

try:
import _winreg
Expand Down Expand Up @@ -42,7 +44,6 @@ def __init__(self,ser,cb):
def run(self):
while self.running:
l = self.ser.readline()
print l
self.cb(l)

class serialCom():
Expand All @@ -52,6 +53,12 @@ def __init__(self,rxCallback):
return

def connect(self,port,baud=115200):
if "Linux" in platform.system():
connection = serial.serial_for_url(port, baud, timeout=2, rtscts=True)
time.sleep(0.1)
connection.close()
time.sleep(2)

self.ser = serial.Serial(port, baud)
self.rxth = serialRead(self.ser,self.rxcb)
self.rxth.setDaemon(True)
Expand All @@ -68,6 +75,7 @@ def send(self,msg):
if self.ser == None:
return
self.ser.write(msg)
self.ser.flush()



Expand Down

0 comments on commit a92a327

Please sign in to comment.