Skip to content

Commit 524ec60

Browse files
committed
minor fixes on the debugging side
1 parent 3844a8c commit 524ec60

8 files changed

Lines changed: 54 additions & 6 deletions
1.23 MB
Binary file not shown.
780 KB
Binary file not shown.
-856 KB
Binary file not shown.

binaries/latest/fwServer.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
# dummy_caddy_like_server.py
2+
'''
3+
mv /Users/bene/Dropbox/Dokumente/Promotion/PROJECTS/uc2-ESP/.pio/build/UC2_3_CAN_HAT_Master_v2/firmware.bin /Users/bene/Dropbox/Dokumente/Promotion/PROJECTS/UC2-REST/binaries/latest/UC2_3_CAN_HAT_Master_v2.bin
4+
mv /Users/bene/Dropbox/Dokumente/Promotion/PROJECTS/uc2-ESP/.pio/build/seeed_xiao_esp32s3_can_slave_motor/firmware.bin /Users/bene/Dropbox/Dokumente/Promotion/PROJECTS/UC2-REST/binaries/latest/esp32_seeed_xiao_esp32s3_can_slave_motor.bin
5+
'''
26
from fastapi import FastAPI, Request, HTTPException
37
from fastapi.responses import (
48
JSONResponse,
-781 KB
Binary file not shown.

uc2rest/canota.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,11 +420,11 @@ def _streaming_upload_worker(self, can_id, port, baud, firmware_data, firmware_s
420420
# Step 2: Open raw serial connection
421421
if status_callback:
422422
status_callback(f"Opening streaming connection on {port} at {baud} baud...", True)
423-
423+
if type(port) == serial.tools.list_ports_common.ListPortInfo:
424+
port = port.device
424425
ser = serial.Serial(port, baud, timeout=0.1)#, write_timeout=1.0)
425426
time.sleep(0.5)
426427
self._drain_serial(ser)
427-
428428
# Step 3: Send streaming start command via JSON
429429
if status_callback:
430430
status_callback(f"Initializing streaming session for CAN ID {can_id}...", True)

uc2rest/home.py

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ def xyztTo1230(self, axis):
239239
return 0
240240
return axis
241241

242-
def home(self, axis=None, timeout=None, speed=None, direction=None, endposrelease=None, endstoppolarity=None, endstoptimeout=10000, isBlocking=False, preMove=True):
242+
def home(self, axis=None, timeout=None, speed=None, direction=None, endposrelease=None, endstoppolarity=None, endstoptimeout=10000, isBlocking=False, preMove=False):
243243
'''
244244
axis = 0,1,2,3 or 'A, 'X','Y','Z'
245245
timeout => when to stop homing (it's a while loop on the MCU)
@@ -290,7 +290,22 @@ def home(self, axis=None, timeout=None, speed=None, direction=None, endposreleas
290290

291291
# construct json string
292292
path = "/home_act"
293-
293+
'''
294+
{
295+
"task": "/home_act",
296+
"qid": 3,
297+
"home": {
298+
"steppers": [{
299+
"stepperid": 2,
300+
"timeout": 40000,
301+
"speed": 20000,
302+
"direction": -1,
303+
"endstoppolarity": 1,
304+
"endoffset": 5000
305+
}]
306+
}
307+
}
308+
'''
294309
payload = {
295310
"task": path,
296311
"home":{
@@ -300,7 +315,8 @@ def home(self, axis=None, timeout=None, speed=None, direction=None, endposreleas
300315
"timeout":endstoptimeout,
301316
"speed":abs(speed),
302317
"direction":direction,
303-
"endstoppolarity":endstoppolarity
318+
"endstoppolarity":endstoppolarity,
319+
"endoffset": endposrelease
304320
}]
305321
}}
306322

@@ -312,3 +328,28 @@ def home(self, axis=None, timeout=None, speed=None, direction=None, endposreleas
312328

313329
return r
314330

331+
332+
def stop_home(self, axis, timeout=1):
333+
''' stop the homing process '''
334+
path = "/home_act"
335+
'''
336+
{
337+
"task": "/home_act",
338+
"stop": true,
339+
"home": {
340+
"steppers": [{
341+
"stepperid": 2
342+
}]
343+
}
344+
}'''
345+
payload = {
346+
"task": path,
347+
"stop": True,
348+
"home":{
349+
"steppers": [
350+
{
351+
"stepperid": axis,
352+
}]
353+
}}
354+
r = self._parent.post_json(path, payload, timeout=timeout)
355+
return r

uc2rest/mserial.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,10 @@ def sendMessage(self, command, nResponses=1, timeout = 20):
454454
if self.DEBUG and json_command!="": self._logger.debug("[SendingCommands]:"+str(json_command))
455455
self._write(self.serialdevice, json_command)
456456
except Exception as e:
457-
if self.DEBUG: self._logger.error(e) # TODO: write failed: Device not configured - why?!
457+
if self.DEBUG:
458+
self._logger.error(e) # TODO: write failed: Device not configured - why?!
459+
# attempt to reconnect
460+
self.reconnect()
458461
return "Failed to Send"
459462
self.commands[identifier]=command # FIXME: Need to clear this after the response is received
460463
if nResponses <= 0 or not self.is_connected or self.manufacturer=="UC2Mock":

0 commit comments

Comments
 (0)