Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5

RoboDK定制的司机

#1
Hello,

I have coded a custom driver for RoboDK to connect to Arduino. From RoboDK GUI, connection works and I am able to send commands (from buttons & program) without any issue.

Though, when I want to use Python API and callsetConnectionParamsmethod, I get the error below.
Code:
File "/venv/lib/python3.7/site-packages/robolink/robolink.py", line 4017, in setConnectionParams
self.link._check_status()
File "/venv/lib/python3.7/site-packages/robolink/robolink.py", line 363, in _check_status
raise Exception('Problems running function')
Exception: Problems running function

Here is the connect function from my custom driver:
Code:
def connect(self, host: str, baudrate: int):
if not self._connected:
try:
self._serial = serial.Serial(host, baudrate=baudrate, timeout=0.5)
except serial.serialutil.SerialException:
self._robodk.update_status(1)
return

self._connected = self._serial.is_open

if self._connected:
self._robodk.update_status(4) # Ready
else:
self._robodk.update_status(1) # Connection problems

# ----- #

def print_message(self, message):
print('SMS:' + message)
sys.stdout.flush()

def update_status(self, status):
if status in ROBOTCOM_STATUS:
status = ROBOTCOM_STATUS[status]

self.print_message('{status}'.format(status=status))

This seems to happen during setting of params. Thus, I am kinda lost where to start debugging. Any help is much appreciated.
#2
Can you provide some example code where you set the connection parameters?

If you customized your robot driver you may not need any of the parameters required by default (such as the IP, FTP remote path and FTP credentials).
#3
Here is how I set connection parameters:

Code:
self.rdk_link.setConnectionParams('/dev/cu.usbmodem14201', 9600, '/', 'anonymous', '')
self.rdk_link.Connect()

Inside driver, since this is a serial connection, I use port in RoboDK as baudrate.
#4
Albert, you won't believe how I fixed this issue. I changed name of robot (in RoboDK). Now everything is fine. :)
Seems for some reason RoboDK didn't like the name i gave.
#5
Thank you for letting us know. This is a strange issue though. What name did you change?




Users browsing this thread:
1 Guest(s)