File tree Expand file tree Collapse file tree 1 file changed +4
-8
lines changed Expand file tree Collapse file tree 1 file changed +4
-8
lines changed Original file line number Diff line number Diff line change @@ -80,17 +80,13 @@ def debug(self, s):
80
80
81
81
def write (self , b ):
82
82
'''write some bytes to remove port'''
83
- if len (b ) > 0 :
84
- self .debug ("sending '%s' (0x%02x) of len %u" % (b , ord (b [0 ]), len (b )))
85
- elif self .ucenter_settings .debug > 1 :
86
- self .debug ("sending empty request" )
87
83
while True :
88
84
# note that we send a single empty buffer on len(b)==0
89
85
n = len (b )
90
86
if n > 70 :
91
87
n = 70
92
- buf = [ ord ( x ) for x in b [:n ]]
93
- buf . extend ([ 0 ] * (70 - len (buf ) ))
88
+ buf = bytes ( b [:n ])
89
+ buf += b' \x00 ' * (70 - len (buf ))
94
90
95
91
if self .last_baudrate != self .ucenter_settings .baudrate or self .last_devnum != self .ucenter_settings .devnum :
96
92
baudrate = self .ucenter_settings .baudrate
@@ -140,7 +136,7 @@ def idle_task(self):
140
136
self .sock = None
141
137
return
142
138
# send empty packet if idle
143
- pkt = ''
139
+ pkt = bytes ()
144
140
if len (pkt ) == 0 and now - self .last_write < self .ucenter_settings .delay :
145
141
return
146
142
self .write (pkt )
@@ -155,7 +151,7 @@ def mavlink_packet(self, m):
155
151
return
156
152
data = m .data
157
153
data = m .data [:m .count ]
158
- buf = '' . join ( str ( chr ( x )) for x in data )
154
+ buf = bytes ( data )
159
155
self .debug ("got reply len %u" % len (buf ))
160
156
try :
161
157
self .sock .send (buf )
You can’t perform that action at this time.
0 commit comments