-
Notifications
You must be signed in to change notification settings - Fork 0
/
DireccionF.py
33 lines (30 loc) · 1 KB
/
DireccionF.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import time
import serial
import struct
from queue import Queue
class Direccion:
#ser is an instance of the Serial Class
def __init__(self,puerto):
#puertos = (os.popen("ls /dev/ttyACM*").read()).split()
ser= serial.Serial(
port = x,
baudrate = 9600,
parity = serial.PARITY_NONE,
stopbits = serial.STOPBITS_ONE,
bytesize = serial.EIGHTBITS,
timeout = 10
)
self.ser = ser
def sendDirection(self,angle):
print("Writing in class....")
self.ser.write(angle)
buffer_in = bytearray(1)
bytesToRead = 0
print("esperando")
while(bytesToRead<=0):
bytesToRead = self.ser.inWaiting()
buffer_in=self.ser.readline()
print("{:}".format(buffer_in))
def initialize(self,angle):
print("Writing in class init....")
self.ser.write(angle)