-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdata_from_Raspberry.py
36 lines (34 loc) · 987 Bytes
/
data_from_Raspberry.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
34
35
36
# -*- coding: utf-8 -*-
"""
Created on Mon Jun 28 14:21:01 2021
@author: Leonard
"""
import serial.tools.list_ports
import serial
import time
import numpy as np
import scipy
from scipy.io import loadmat,savemat
ser_rasp = serial.Serial(
port='COM13',
baudrate=115200,
parity=serial.PARITY_NONE,
stopbits=serial.STOPBITS_ONE,
bytesize=serial.EIGHTBITS,
xonxoff = False, #disable software flow control
rtscts = False , #disable hardware (RTS/CTS) flow control
dsrdtr = False, #disable hardware (DSR/DTR) flow control
timeout=0
)
ser_rasp.isOpen()
while ser_rasp.isOpen():
try:
strdata = ser_rasp.readline().decode()
time.sleep(0.1)
position = strdata.split(',')
if len(position) == 6:
square_position = np.array([float(position[0]),float(position[1]),5.0])
print(square_position)
#savemat('position.mat', mdict={'pos':data})
except Exception as e:
print(e)