Skip to content

Commit 92bc190

Browse files
author
ymj-123
committed
fix: debug com: support get configuration and start log cmd
1 parent 730239e commit 92bc190

File tree

1 file changed

+41
-3
lines changed

1 file changed

+41
-3
lines changed

src/aceinna/devices/openrtk/uart_provider.py

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ def __init__(self, communicator):
3535
self.user_logf = None
3636
self.debug_logf = None
3737
self.rtcm_logf = None
38+
self.debug_c_f = None
3839
self.enable_data_log = False
3940
self.prepare_folders()
4041

@@ -158,7 +159,7 @@ def after_setup(self):
158159

159160
funcs = [self.thread_debug_port_receiver, self.thread_rtcm_port_receiver]
160161
for func in funcs:
161-
t = threading.Thread(target=func, args=())
162+
t = threading.Thread(target=func, args=(file_name,))
162163
t.start()
163164

164165
return True
@@ -179,9 +180,46 @@ def on_read_raw(self, data):
179180
if self.user_logf is not None:
180181
self.user_logf.write(data)
181182

182-
def thread_debug_port_receiver(self):
183+
def thread_debug_port_receiver(self, *args, **kwargs):
183184
if self.debug_logf is None:
184185
return
186+
is_get_configuration = 0
187+
file_name = args[0]
188+
self.debug_c_f = open(file_name + '/' + 'configuration.txt',"w")
189+
190+
while True:
191+
if is_get_configuration:
192+
break
193+
cmd_configuration = 'get configuration\r'
194+
self.debug_serial_port.write(cmd_configuration.encode())
195+
try_times = 20
196+
for i in range(try_times):
197+
data_buffer = self.debug_serial_port.read(500)
198+
if len(data_buffer):
199+
try:
200+
#print('len = {0}'.format(len(data_buffer)))
201+
str_data = bytes.decode(data_buffer)
202+
#print('{0}'.format(str_data))
203+
json_data = json.loads(data_buffer)
204+
for key in json_data.keys():
205+
if key == 'openrtk configuration':
206+
print('{0}'.format(json_data))
207+
if self.debug_c_f:
208+
self.debug_c_f.write(str_data)
209+
self.debug_c_f.close()
210+
is_get_configuration = 1
211+
if is_get_configuration:
212+
break
213+
except Exception as e:
214+
#print('DEBUG PORT Thread:json error:', e)
215+
#the json will not be completed
216+
pass
217+
218+
219+
cmd_log = 'log com3 P1\r'
220+
self.debug_serial_port.write(cmd_log.encode())
221+
222+
# log data
185223
while True:
186224
try:
187225
data = bytearray(self.debug_serial_port.read_all())
@@ -193,7 +231,7 @@ def thread_debug_port_receiver(self):
193231
else:
194232
time.sleep(0.001)
195233

196-
def thread_rtcm_port_receiver(self):
234+
def thread_rtcm_port_receiver(self, *args, **kwargs):
197235
if self.rtcm_logf is None:
198236
return
199237
while True:

0 commit comments

Comments
 (0)