gottliebtfreitag / inspexel

the swiss army knife for dynamixel servo motors
ISC License
21 stars 3 forks source link

Fails with: cannot do TIOCSSERIAL #3

Closed ubald closed 2 years ago

ubald commented 5 years ago

Hi, I get the following when trying to run inspexel:

$ inspexel detect --device /dev/ttyACM0 --baudrate 57600 --protocol_version 2 --other_baudrates 57600
# trying protocol version 2
## trying baudrate: 57600
cannot do TIOCSSERIAL on /dev/ttyACM0 Operation not permitted

(I used --other_baudrates because otherwise it was starting with 57142 which seemed kind of strange)

I tried commenting out https://github.com/gottliebtfreitag/inspexel/blob/3f2c37d211906ab4ba5feb695edba9d589a17f56/src/simplyfile/SerialPort.cpp#L54-L57 in case it was causing the issue. But without these lines only the error would go but nothing else got detected.

I use an OpenCM9.04 that just echos what it receives between both serial ports and it works with the DynamixelSDK.

Thanks in advance, the tool looks awesome, I can't wait to use it!

nerdmaennchen commented 5 years ago

heyhey,

I'm glad you try our tool! Just to be sure: Does you user have permission to access /dev/ttyACM0? If you're using ubuntu you have to be in the dialout group (I think). Anyways, to check please look at the group-owner of the device by runnung: $ ls -l /dev/ttyACM0 in my case i get the following: crw-rw-rw- 1 root uucp 4, 64 3. Feb 08:35 /dev/ttyACM0 which means, the device is owned by user root but users that are part of the uucp group can access the device. uucp might not be the correct group name on your system though.

Could you double check if you have the right permissions? If it still fails, could you give us some hints about your setup (distribution, kernel, the whole enchilada)?

all the best, Lutz

ubald commented 5 years ago

Hi, I added myself to the dialout group, I am indeed using Ubuntu 18.04 kernel 4.18.0-16-generic.

I just tested again and surprisingly, today, it detects the motors :tada:

$ inspexel detect
# trying protocol version 1
## trying baudrate: 57142
cannot do TIOCSSERIAL on /dev/serial/by-id/usb-ROBOTIS_ROBOTIS_ComPort-if00 Operation not permitted
## trying baudrate: 1000000
cannot do TIOCSSERIAL on /dev/serial/by-id/usb-ROBOTIS_ROBOTIS_ComPort-if00 Operation not permitted
# trying protocol version 2
## trying baudrate: 57142
cannot do TIOCSSERIAL on /dev/serial/by-id/usb-ROBOTIS_ROBOTIS_ComPort-if00 Operation not permitted
1 XL430-W250 (1060) Layout MX_V2
2 XL430-W250 (1060) Layout MX_V2
3 XL430-W250 (1060) Layout MX_V2
## trying baudrate: 1000000
cannot do TIOCSSERIAL on /dev/serial/by-id/usb-ROBOTIS_ROBOTIS_ComPort-if00 Operation not permitted
1 XL430-W250 (1060) Layout MX_V2
2 XL430-W250 (1060) Layout MX_V2
3 XL430-W250 (1060) Layout MX_V2

But --read_all has trouble getting the values:

$ inspexel --read_all                                                                                                                                                                                                                                         10.2s
# trying protocol version 1
## trying baudrate: 57142
cannot do TIOCSSERIAL on /dev/serial/by-id/usb-ROBOTIS_ROBOTIS_ComPort-if00 Operation not permitted
## trying baudrate: 1000000
cannot do TIOCSSERIAL on /dev/serial/by-id/usb-ROBOTIS_ROBOTIS_ComPort-if00 Operation not permitted
# trying protocol version 2
## trying baudrate: 57142
cannot do TIOCSSERIAL on /dev/serial/by-id/usb-ROBOTIS_ROBOTIS_ComPort-if00 Operation not permitted
1 XL430-W250 (1060) Layout MX_V2
2 XL430-W250 (1060) Layout MX_V2
3 XL430-W250 (1060) Layout MX_V2
couldn't retrieve detailed information from all motors

0x00 2  R ROM                  Model Number - Model Number
0x02 4  R ROM             Model Information - Model Information
0x06 1  R ROM           Version of Firmware - Firmware Version
0x07 1 RW ROM                            ID - Dynamixel ID
0x08 1 RW ROM                     Baud Rate - Communication Baud Rate
0x09 1 RW ROM             Return Delay Time - Response Delay Time
0x0a 1 RW ROM                    Drive Mode - Drive Mode
0x0b 1 RW ROM                Operating Mode - Operating Mode
0x0c 1 RW ROM          Secondary(Shadow) ID - Secondary(Shadow) ID
0x0d 1 RW ROM              Protocol Version - Protocol Version
0x14 4 RW ROM                 Homing Offset - Home Position Offset
0x18 4 RW ROM              Moving Threshold - Velocity Threshold for Movement Detection
0x1f 1 RW ROM             Temperature Limit - Maximum Internal Temperature Limit
0x20 2 RW ROM             Max Voltage Limit - Maximum Voltage Limit
0x22 2 RW ROM             Min Voltage Limit - Minimum Voltage Limit
0x24 2 RW ROM                     PWM Limit - Maximum PWM Limit
0x26 2 RW ROM                 Current Limit - Maximum Current Limit
0x28 4 RW ROM            Acceleration Limit - Maximum Acceleration Limit
0x2c 4 RW ROM                Velocity Limit - Maximum Velocity Limit
0x30 4 RW ROM            Max Position Limit - Maximum Position Limit
0x34 4 RW ROM            Min Position Limit - Minimum Position Limit
0x3f 1 RW ROM                      Shutdown - Shutdown Dynamixel
0x40 1 RW RAM                 Torque Enable - Motor Torque On/Off
0x41 1 RW RAM                           LED - Status LED On/Off
0x44 1 RW RAM           Status Return Level - Select Types of Status Return
0x45 1  R RAM        Registered Instruction - Check Reception of Instruction
0x46 1  R RAM         Hardware Error Status - Hardware Error Status
0x4c 2 RW RAM               Velocity I Gain - I Gain of Velocity
0x4e 2 RW RAM               Velocity P Gain - P Gain of Velocity
0x50 2 RW RAM               Position D Gain - D Gain of Position
0x52 2 RW RAM               Position I Gain - I Gain of Position
0x54 2 RW RAM               Position P Gain - P Gain of Position
0x58 2 RW RAM          Feedforward 2nd Gain - 2nd Gain of Feed-Forward
0x5a 2 RW RAM          Feedforward 1st Gain - 1st Gain of Feed-Forward
0x62 1 RW RAM                  Bus Watchdog - Dynamixel Bus Watchdog
0x64 2 RW RAM                      Goal PWM - Target PWM Value
0x66 2 RW RAM                  Goal Current - Target Current Value
0x68 4 RW RAM                 Goal Velocity - Target Velocity Value
0x6c 4 RW RAM          Profile Acceleration - Acceleration Value of Profile
0x70 4 RW RAM              Profile Velocity - Velocity Value of Profile
0x74 4 RW RAM                 Goal Position - Target Position Value
0x78 2  R RAM                 Realtime Tick - Count Time in millisecond
0x7a 1  R RAM                        Moving - Movement Status
0x7b 1  R RAM                 Moving Status - Detailed Information of Movement Status
0x7c 2  R RAM                   Present PWM - Current PWM Value
0x7e 2  R RAM               Present Current - Current Current Value
0x80 4  R RAM              Present Velocity - Current Velocity Value
0x84 4  R RAM              Present Position - Current Position Value
0x88 4  R RAM           Velocity Trajectory - Target Velocity Trajectory Generated by Profile
0x8c 4  R RAM           Position Trajectory - Target Position Trajectory Generated by Profile
0x90 2  R RAM         Present Input Voltage - Current Input Voltage
0x92 1  R RAM           Present Temperature - Current Internal Temperature
0xa8 56 RW RAM    Indirect Addresses Block 1 - Indirect Addresses Block 1
0xe0 28 RW RAM         Indirect Data Block 1 - Indirect Data Block 1
0x242 56 RW RAM    Indirect Addresses Block 2 - Indirect Addresses Block 2
0x27a 28 RW RAM         Indirect Data Block 2 - Indirect Data Block 2
nerdmaennchen commented 5 years ago

Your report is pretty interesting!

We've build inspexel for the purpose of beeing used with a usb2dynamixel (a rather expensive usb-to-rs485 or usb-to-uart transceiver). Inside the usb2dynamixel is usually an FTDI-chip that does the translation from usb to UART. So all the magic internals of inspexel rely on the availability of a serial device that behaves like a "proper" serial device.

Apparently inside the OpenCM there is no such thing (which is good because it is actually not needed), because the USB wires connect directly to the microcontroler (see schematics )

The register set of the OpenCM does in fact have a baudrate register to define the outgoing baudrate. Defining it "again" via the default-serial-device-usb-way would indeed be semantically incorrect, so I think they simply don't support that operation (that's why you get that error message).

I am pretty surprised though that some things are actually working with the OpenCM!

I do have to apologize that in the short run we're not able to help you with your problem since we don't have the required hardware. But if we do get hold on a OpenCM, I think it is worth adding it as a supported serial device to inspexel.

Also I'd like to thank you for using our software and contacting us!

Cheers, Lutz

ubald commented 5 years ago

I see, I guess it's my fault for wanting to go for the cheap OpenCM option :stuck_out_tongue:

Thanks for the info anyway!

nerdmaennchen commented 5 years ago

There is no fault on your part!

I'd like to keep this ticket open to have a reminder to add this functionality to inspexel. Currently (and for the remainder of this year and a bit more) I'm traveling, but maybe @SGSSGene could take a look on this issue.

Cheers, Lutz

SGSSGene commented 5 years ago

Thanks for your input. There seems to be multiple issues.

  1. OpenCM register can't be accessed through inspexel (tables are missing)
  2. Inspexel ignores if serial baud rate couldn't be set and just continues.
  3. Weird output when tables for motors/devices are missing.
  4. Might need an extra mode to iterate through different baudrates (needs to set registers on openCM)

Sadly I don't have a OpenCM9.04 here. So I can't try any of the software. I have created a branch with OpenCM9.04 register tables added and dealing a little better with the case that baudrate can't be set. This should work for the 'detect' and 'fuse' command (all others I just ignored for now, but probably most will work anyways). Could you try it out? checkout branch: git checkout 003/feat/fails_with_opencm You can start the software without baudrate or protocol (it should try both protocols, and baudrate can't be set on openCM devices) inspexel detect --device /dev/ttyACM0

ubald commented 5 years ago

Wow, that was quick! I can’t try it right now as I am at work but I’ll give it a go later tonight or tomorrow.

As for the OpenCM tables, I’m afraid there was a misunderstanding. What I am doing is using the OpenCM with code that makes it behave like an OpenCR with usb_to_dxl. I took that code and adapted it to run on the OpenCM. That's what I meant when I said:

I use an OpenCM9.04 that just echos what it receives between both serial ports and it works with the DynamixelSDK.

ubald commented 5 years ago

I just wanted to let you know that I have since switched to a U2D2 and I was able to use inspexel with it.

SGSSGene commented 5 years ago

Thanks for letting us know. I tried to get my hands on a OpenCM 9.04 to check on the error my self, but couldn't get an OpenCM so quickly. My guess is that some parts of the "usb_to_dxl" code is running to slow and inspexel timeouts.

Setting the "baud rate" of the OpenCM fails, which is fine, it just means inspexel can't scan on different baud rate. It just rescans on the fixed baud rate set by the "usb_to_dxl".

The detection of the motors "XL430-W250 (1060) Layout MX_V2" itself seems to work. When trying to detect a motor it reads the first two bytes of the register tables to determine which Model Number that motor has. This show that parts of the "usb_to_dxl" is working.

When running "--read_all" all flag inspexel does a second pass where it reads all registers of the motor at once. This is a lot of data. It looks like this operation is not successful.