무선 센서 EBMotion(EBIMU24G + EBRCV24G)용 파이썬 예제입니다. 
윈도우즈 또는 리눅스 운영체제에서 사용할 수 있습니다. 
연결된 시리얼 포트를 통해 ebimu 센서의 데이터를 읽고 항목 단위로 저장한 뒤 출력합니다. 
pyserial 모듈을 설치 후 코드를 실행해야 합니다. 
pip install pyserial  
회전 데이터 외에 센서의 추가적인 데이터(각속도, 가속도..)를 얻으려면 터미널 프로그램(EBTerminal등)에서 추가 데이터 출력이 나오도록 먼저 설정하시기 바랍니다. 
[python 예제 1]
| 
 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 
 | 
 import sys  
import serial 
import string 
#comport_num = "/dev/ttyUSB0" 
#comport_num = "COM3" 
#comport_baudrate = 921600 
comport_num = input("EBIMU Port(e.g., COM3 or /dev/ttyUSB0):") 
comport_baudrate = input("Baudrate(e.g., 921600):") 
ser = serial.Serial(port=comport_num,baudrate=comport_baudrate) 
while 1: 
    line = ser.readline() 
    line = line.decode('utf-8') 
    words = line.split(",")    # Fields split 
    if(-1 < words[0].find('-')) : 
        chid = words[0] 
        chid = chid.split('-') 
        sid = int(chid[1]) 
    else: 
        continue 
    for word in words: 
        print(word + ' ', end='') 
ser.close 
 | 
cs | 
[python 예제 2]
| 
 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 
37 
38 
39 
40 
41 
42 
43 
44 
45 
46 
47 
48 
49 
 | 
 import sys  
import serial 
import string 
import threading 
import time 
#comport_num = "/dev/ttyUSB0" 
#comport_num = "COM3" 
#comport_baudrate = 921600 
comport_num = input("EBIMU Port(e.g., COM3 or /dev/ttyUSB0):") 
comport_baudrate = input("Baudrate(e.g., 921600):") 
ser = serial.Serial(port=comport_num,baudrate=comport_baudrate) 
sdata = [] 
sid = 0 
updated = 0 
def data_parser(): 
    global sdata 
    global sid 
    global updated 
    while 1: 
        line = ser.readline() 
        line = line.decode('utf-8') 
        words = line.split(",")    # Fields split 
        if(-1 < words[0].find('-')) : 
            chid = words[0] 
            chid = chid.split('-') 
            sid = int(chid[1]) 
            words = words[1:] 
            sdata = list(map(float, words)) # float type 
            updated=1 
th = threading.Thread(target=data_parser) 
th.start() 
while 1: 
    time.sleep(0.0001) 
    if(updated == 1): 
        updated=0 
        print("%d " %sid, end="") 
        print(sdata) 
ser.close 
 | 
cs |