Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SBUS on Linux: replace termios with termios2 #14083

Merged
merged 4 commits into from
Feb 2, 2020

Conversation

SalimTerryLi
Copy link
Contributor

Describe problem solved by this pull request
Previous version of code could not set the serial device properly, which leads to incorrect read of _rcs_buf. This PR solves that problem.

Describe your solution
Code comes from existing drivers/linux_sbus, which works well.
A problem still exists that rc_input will report
ERROR [px4_work_queue] unknown serial port: /dev/ttyAMA0
for that customised ttyAMA0 is not defined which is necessary for function px4::serial_port_to_wq()

Test data / coverage

pxh> rc_input status
INFO  [rc_input] Running
INFO  [rc_input] Max update rate: 250 Hz
INFO  [rc_input] Serial device: /dev/ttyAMA0
INFO  [rc_input] RC scan state: SBUS, locked: yes
INFO  [rc_input] CRSF Telemetry: no
INFO  [rc_input] SBUS frame drops: 0
rc_input: cycle time: 6006 events, 81508us elapsed, 13.57us avg, min 8us max 89us 5.316us rms
rc_input: publish interval: 1600 events, 14997.50us avg, min 11937us max 19990us 1733.078us rms
 input_rc_s
	timestamp: 4067569737  (0.008766 seconds ago)
	timestamp_last_signal: 4067569737
	channel_count: 18
	rssi: 255
	rc_lost_frame_count: 0
	rc_total_frame_count: 0
	rc_ppm_frame_length: 0
	values: [1512, 1509, 1934, 1522, 1094, 1094, 1514, 1514, 1094, 1094, 1094, 1094, 944, 944, 1514, 1514, 998, 998]
	rc_failsafe: False
	rc_lost: False
	input_source: 9

@SalimTerryLi SalimTerryLi changed the title replace termios with termios2 SBUS on Linux: replace termios with termios2 Feb 2, 2020
@dagar
Copy link
Member

dagar commented Feb 2, 2020

A problem still exists that rc_input will report
ERROR [px4_work_queue] unknown serial port: /dev/ttyAMA0
for that customised ttyAMA0 is not defined which is necessary for function px4::serial_port_to_wq()

Feel free to add it here if you'd like - https://github.com/PX4/Firmware/blob/9d2a37b35d3af1f8848565ee8eedd6aa94a19251/platforms/common/px4_work_queue/WorkQueueManager.cpp#L166-L202

@dagar
Copy link
Member

dagar commented Feb 2, 2020

Could you structure the ifdef so that the decoder initialise section is run in both cases?

https://github.com/PX4/Firmware/blob/9d2a37b35d3af1f8848565ee8eedd6aa94a19251/src/lib/rc/sbus.cpp#L224-L229

@dagar dagar self-requested a review February 2, 2020 16:57
@SalimTerryLi
Copy link
Contributor Author

SalimTerryLi commented Feb 2, 2020

A problem still exists that rc_input will report
ERROR [px4_work_queue] unknown serial port: /dev/ttyAMA0
for that customised ttyAMA0 is not defined which is necessary for function px4::serial_port_to_wq()

Feel free to add it here if you'd like -

https://github.com/PX4/Firmware/blob/9d2a37b35d3af1f8848565ee8eedd6aa94a19251/platforms/common/px4_work_queue/WorkQueueManager.cpp#L166-L202

Is it OK to add something like ttyDEFAULT and wq_configurations::UART_DEFAULT? ttyAMA0 is pick up from my own board but it can be ttyUSB0 as well.

EDIT: Mostly like to remove that error and create some place for unrecognized UART instead of hp_default?

@dagar
Copy link
Member

dagar commented Feb 2, 2020

Is it OK to add something like ttyDEFAULT and wq_configurations::UART_DEFAULT? ttyAMA0 is pick up from my own board but it can be ttyUSB0 as well.

EDIT: Mostly like to remove that error and create some place for unrecognized UART instead of hp_default?

The point of it is to have a thread dedicated to each physical bus. At the moment it's all static, but it could be more flexible in the future (needs some thought and rework).

I would either:

  1. Add a /dev/ttyAMA0, maybe behind a __PX4_LINUX define seems like the less bad option, unless you'd like to explore making the PX4 WQs more runtime configurable.
  2. Make it UART_UNKNOWN instead of UART_CUSTOM

@dagar dagar merged commit e0abe70 into PX4:master Feb 2, 2020
@SalimTerryLi SalimTerryLi deleted the pr-linux_sbus_config-fix branch February 2, 2020 19:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants