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

AP_RCProtocol: IBUS hack for FlySky IA6 receiver #28306

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

arg7
Copy link
Contributor

@arg7 arg7 commented Oct 4, 2024

This PR adds support for slightly modified IBUS protocol for cheap FlySky IA6 receiver.
See https://www.youtube.com/watch?v=qEUB6GJQmRc

Copy link
Contributor

@peterbarker peterbarker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me know if you want help structuring this as a subclass.

We also need to augment the test suite in RCProtocolTest to add a regression test for this protocol - have a look for ibus_bytes in there to see what's required.

@@ -69,23 +110,32 @@ void AP_RCProtocol_IBUS::_process_byte(uint32_t timestamp_us, uint8_t b)
const bool have_frame_gap = (timestamp_us - byte_input.last_byte_us >= 2000U);
byte_input.last_byte_us = timestamp_us;


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bad whitespace change

Comment on lines +130 to +131
if (byte_input.ofs == 0)
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (byte_input.ofs == 0)
{
if (byte_input.ofs == 0) {

@@ -20,10 +20,12 @@

#include "AP_RCProtocol_IBUS.h"

static int ia6_hack = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to have an AP_RCProtocol_IBUS_IA6 subclass so that other users can use this modified decoder by using the custom build server.

{
uint32_t chksum = 96;
uint16_t chksum = 96;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure this is correct?

ie. the checksum definition must state that your result is modulo UINT16_MAX. If it does not then you may pass the checksum when you shouldn't.

if (b != 0x20 && byte_input.ofs == 0) {
// definately not IBUS, missing header byte

if ( !( (b == 0x20) || (b == 0x55) ) && byte_input.ofs == 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will need a virtual method to return expected header byte

byte_input.buf[byte_input.ofs++] = b;

if (byte_input.ofs == sizeof(byte_input.buf)) {
if (byte_input.ofs == (sizeof(byte_input.buf)-ia6_hack)) // IA6 has one byte less
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will need a callback for expected number of bytes in a packet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants