Exemplo n.º 1
0
 def openPort(self, port='/dev/ttyUSB0', baudrate=115200):
     self.ser = SerialComm.connectToSerialPort(port, baudrate)
     self.thread = threading.Thread(target=self.readAndUpdate)
     self.thread.daemon = True
     self.thread.start()
Exemplo n.º 2
0
#!/usr/bin/env python2
# -*- coding: utf-8 -*-

import serial
import time
import slip.SerialComm as SerialComm
import slip.ProtoSLIP as ProtoSLIP
import threading
import wx

portName = "/dev/ttyACM0"
baudRate = 115200
go = 1

serialPort = SerialComm.connectToSerialPort(portName, baudRate)


def readAndUpdate():
    while (go):
        values = []
        # Lire un paquet SLIP
        bytes = ProtoSLIP.decodeFromSLIP(serialPort)
        # Faire quelque chose avec ce paquet:
        for i in xrange(0, len(bytes), 2):
            values.append(bytes[i] << 8 | bytes[i + 1])
        print values
        time.sleep(0.001)
    serialPort.flush()
    SerialComm.disconnectFromSerialPort(serialPort)
    print "Port closed."
    return
Exemplo n.º 3
0
 def openPort(self, port='/dev/ttyUSB0', baudrate=115200):
     self.ser = SerialComm.connectToSerialPort(port, baudrate)
     self.thread = threading.Thread(target=self.readAndUpdate)
     self.thread.daemon = True
     self.thread.start()