This repository has been archived by the owner on Oct 15, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 37
/
port.py
47 lines (36 loc) · 1.73 KB
/
port.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
37
38
39
40
41
42
43
44
45
46
47
# ReachView code is placed under the GPL license.
# Written by Egor Fedorov (egor.fedorov@emlid.com)
# Copyright (c) 2015, Emlid Limited
# All rights reserved.
# If you are interested in using ReachView code as a part of a
# closed source project, please contact Emlid Limited (info@emlid.com).
# This file is part of ReachView.
# ReachView is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# ReachView is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with ReachView. If not, see <http://www.gnu.org/licenses/>.
from os import system
def sh(script):
system("bash -c '%s'" % script)
# change baudrate to 230400
def br230400():
cmd = ["echo", "-en", '"\\xb5\\x62\\x06\\x00\\x01\\x00\\x01\\x08\\x22\\xb5\\x62\\x06\\x00\\x14\\x00\\x01\\x00\\x00\\x00\\xd0\\x08\\x00\\x00\\x00\\x84\\x03\\x00\\x07\\x00\\x03\\x00\\x00\\x00\\x00\\x00\\x84\\xe8\\xb5\\x62\\x06\\x00\\x01\\x00\\x01\\x08\\x22"', ">", "/dev/ttyMFD1"]
cmd = " ".join(cmd)
sh(cmd)
# change baudrate to 230400 from any previous baudrates
def changeBaudrateTo230400():
# typical baudrate values
br = ["4800", "9600", "19200", "38400", "57600", "115200", "230400"]
cmd = ["stty", "-F", "/dev/ttyMFD1"]
for rate in br:
cmd.append(str(rate))
cmd_line = " ".join(cmd)
sh(cmd_line)
br230400()
cmd.pop()