- Posts: 3333
Support for walkera telemetry.
- vlad_vy
- Offline
devo_cyrf6936.c
CYRF_WriteRegister(CYRF_06_RX_CFG, 0x48);
dsm2_cyrf6936.c
{CYRF_06_RX_CFG, 0x48},
Please Log in or Create an account to join the conversation.
- linux-user
- Offline
- Posts: 271
- 4x 'RST CYRF' message what is expected on my TX
- connection still possible
- telemetry working prefect
- control working prefect
OT:
- when telemetry alarm is triggered it jumps to telemetry page (maybe debatable).
- data logging is not working since a long time ago.
Please Log in or Create an account to join the conversation.
- vlad_vy
- Offline
- Posts: 3333
Please Log in or Create an account to join the conversation.
- Gyrfalcon
- Offline
- Posts: 23
For the new tests, I separated the receiver and transmitter to about 3 meters and setup a parallel test system. Both systems are powered at 100uW and have had good telemetry and control reception. I think the Rst CYRF message occurs sometimes when I bind or re-bind one of the systems, or when I turn on an additional transmitter (Devo8S, 100mW). But I can not get a consistent response, so it may be something else.
I also noted that I can jam the telemetry signal with the addition transmitter (most of the time), once it is moved away or turned off, the telemetry is restored. The receivers do not seam to be affected by a third transmitter and I still see smooth servo functionality.
At the end my torcher testing, I did have a LOC to the RX2637. The RX1202, which was dual bound to the same transmitter was still connected, so I don't think it was caused by a transmitter problem.
BTW, I tested Indigo's latest build, deviation-devo12-v4.0.1-ee1b869 and it seams to perform about the same. Telemetry and receiver connections were good. Unfortunately, it also generates a few Rst CYRF messages, similar to Vlad's code. I had both versions running at the same time, and sometimes it appeared that they generated Rst CYRF messages at the same time, but other times they were independent. Wish I could get consistent, results.
I was happy to see that Indigo changed the alarm page jump code as I suggested, Thanks!
Please Log in or Create an account to join the conversation.
- vlad_vy
- Offline
- Posts: 3333
} else {
CYRF_SetTxRxMode(RX_EN); //Receive mode
CYRF_WriteRegister(CYRF_05_RX_CTRL, 0x80); //Prepare to receive (do not enable any IRQ)
//delay = 900;
//txState = 9;
}
or at least decrease delay
} else {
CYRF_SetTxRxMode(RX_EN); //Receive mode
CYRF_WriteRegister(CYRF_05_RX_CTRL, 0x80); //Prepare to receive (do not enable any IRQ)
delay = 800;
txState = 8;
}
Please Log in or Create an account to join the conversation.
- linux-user
- Offline
- Posts: 271
Every ~4h one "Rst CYRF" messages means to me a prevented LOC
Please Log in or Create an account to join the conversation.
- vlad_vy
- Offline
- Posts: 3333
Please Log in or Create an account to join the conversation.
- Gyrfalcon
- Offline
- Posts: 23
So far, after 9 Hrs, the Debug log is clean, with no "Rst CYRF' messages.
Telemetry looks good and no LOC to either the RX2637 or the RX1202. (Note, the Devo12S was set to 100uW, with about 3 meters distance between TX and RX, same as before.)
Please Log in or Create an account to join the conversation.
- Gyrfalcon
- Offline
- Posts: 23
Please Log in or Create an account to join the conversation.
- vlad_vy
- Offline
- Posts: 3333
CYRF_WriteRegister(CYRF_06_RX_CFG, 0x48);
static u16 devo_telemetry_cb()
{
int delay;
if (txState == 0) {
DEVO_BuildPacket();
CYRF_WriteDataPacket(packet);
txState = 1;
return 900;
}
if (txState == 1) {
int i = 0;
u8 reg;
while (! ((reg = CYRF_ReadRegister(0x04)) & 0x02)) {
if (++i >= NUM_WAIT_LOOPS)
break;
}
if (((reg & 0x22) == 0x20) || (CYRF_ReadRegister(0x02) & 0x80)) {
CYRF_Reset();
cyrf_init();
cyrf_set_bound_sop_code();
CYRF_ConfigRFChannel(*radio_ch_ptr);
//printf(" Rst CYRF\n");
delay = 1500;
txState = 3;
} else {
if (state == DEVO_BOUND) {
/* exit binding state */
state = DEVO_BOUND_3;
cyrf_set_bound_sop_code();
}
if(pkt_num == 0 || bind_counter > 0) {
delay = 1500;
txState = 3;
} else {
CYRF_SetTxRxMode(RX_EN); //Receive mode
CYRF_WriteRegister(CYRF_05_RX_CTRL, 0x80); //Prepare to receive (do not enable any IRQ)
txState = 2;
return 1200;
}
}
}
if(txState == 2) { // this won't be true in emulator so we need to simulate it somehow
//Read telemetry if needed
if(CYRF_ReadDataPacketLen(packet) == 1) {
parse_telemetry_packet(packet);
}
#ifdef EMULATOR
u8 telem_bit = rand32() % 7; // random number in [0, 7)
packet[0] = TELEMETRY_ENABLE + telem_bit; // allow emulator to simulate telemetry parsing to prevent future bugs in the telemetry monitor
//printf("telem 1st packet: 0x%x\n", packet[0]);
for(int i = 1; i < 13; i++)
packet[i] = rand32() % 256;
parse_telemetry_packet(packet);
for(int i = 0; i < TELEM_UPDATE_SIZE; i++)
Telemetry.updated[i] = 0xff;
#endif
delay = 300;
txState = 3;
}
if(txState == 3) {
CYRF_SetTxRxMode(TX_EN); //Write mode
if(pkt_num == 0) {
//Keep tx power updated
CYRF_WriteRegister(CYRF_03_TX_CFG, 0x08 | Model.tx_power);
radio_ch_ptr = radio_ch_ptr == &radio_ch[2] ? radio_ch : radio_ch_ptr + 1;
CYRF_ConfigRFChannel(*radio_ch_ptr);
}
txState = 0;
}
return delay;
}
Changed files (printf(" Rst CYRF\n") commented out):
Please Log in or Create an account to join the conversation.
- linux-user
- Offline
- Posts: 271
- 1x 'RST CYRF' message what is expected on my TX
- connection still possible
- telemetry working prefect
- control working prefect
- telemetry alarm working as "advertised" (Gyrfalcon's hybrid)
So far with my limited test capabilities both versions are working
vlad-deviation-devo10-v4.0.1-f628e56
indigo-deviation-devo10-v4.0.1-ee1b869
Please Log in or Create an account to join the conversation.
- vlad_vy
- Offline
- Posts: 3333
Please Log in or Create an account to join the conversation.
- vlad_vy
- Offline
- Posts: 3333
First time I see rock solid "Flight Log" values for DSMX protocol, without any sporadical erroneous values. But it can be illusion.
int CYRF_ReadDataPacketLen(u8 dpbuffer[])
{
u8 rx_state;
u8 length;
rx_state = CYRF_ReadRegister(CYRF_07_RX_IRQ_STATUS);
if (rx_state & 0x02) { // receive complete
if (!(rx_state & 0x01)) { // RXC=1, RXE=0 then 2nd check is required (debouncing)
rx_state |= CYRF_ReadRegister(CYRF_07_RX_IRQ_STATUS);
}
length = CYRF_ReadRegister(CYRF_09_RX_COUNT);
if ((rx_state & 0x05) || (CYRF_ReadRegister(CYRF_08_RX_STATUS) & 0x08)) { //if any error or CRC error
if( !(CYRF_ReadRegister(CYRF_06_RX_CFG) & 0x02)) { //if buffer overwrite disabled (RXOW bit = 0)
// bad data, empty buffer
CYRF_WriteRegister(CYRF_07_RX_IRQ_STATUS, 0x80); // need to set RXOW before data read
while (length) {
CYRF_ReadRegister(CYRF_21_RX_BUFFER);
length--;
}
}
return 2; //bad data
} else {
// good data (complete with no errors)
CYRF_WriteRegister(CYRF_07_RX_IRQ_STATUS, 0x80); // need to set RXOW before data read
ReadRegisterMulti(CYRF_21_RX_BUFFER, dpbuffer, length);
return 1; //good data
}
}
return 0; //receive not complete
}
Changed files (printf(" Rst CYRF\n") commented out):
Please Log in or Create an account to join the conversation.
- vlad_vy
- Offline
- Posts: 3333
static u16 devo_telemetry_cb()
{
int delay;
if (txState == 0) {
DEVO_BuildPacket();
CYRF_WriteDataPacket(packet);
txState = 1;
return 900;
}
if (txState == 1) {
int i = 0;
u8 reg;
while (! ((reg = CYRF_ReadRegister(0x04)) & 0x02)) {
if (++i >= NUM_WAIT_LOOPS)
break;
}
if (((reg & 0x22) == 0x20) || (CYRF_ReadRegister(0x02) & 0x80)) {
CYRF_Reset();
cyrf_init();
cyrf_set_bound_sop_code();
CYRF_ConfigRFChannel(*radio_ch_ptr);
printf("Rst CYRF\n");
delay = 1500;
txState = 3;
} else {
if (state == DEVO_BOUND) {
/* exit binding state */
state = DEVO_BOUND_3;
cyrf_set_bound_sop_code();
}
if(pkt_num == 0 || bind_counter > 0) {
delay = 1500;
txState = 3;
} else {
CYRF_SetTxRxMode(RX_EN); //Receive mode
CYRF_WriteRegister(CYRF_05_RX_CTRL, 0x80); //Prepare to receive (do not enable any IRQ)
txState = 2;
return 1180;
}
}
}
if(txState == 2) { // this won't be true in emulator so we need to simulate it somehow
//Read telemetry if needed
int i = 0;
u8 rx_status;
while ( !((rx_status = CYRF_ReadRegister(0x07)) & 0x20)) {
if (++i > NUM_WAIT_LOOPS)
break;
}
if((rx_status & 0x03) == 0x02) { // RXC=1, RXE=0 then 2nd check is required (debouncing)
rx_status |= CYRF_ReadRegister(0x07);
}
if ((rx_status & 0x27) == 0x22) { // good data (complete with no errors)
CYRF_WriteRegister(CYRF_07_RX_IRQ_STATUS, 0x80); //Prepare to read buffer
CYRF_ReadDataPacket(packet);
parse_telemetry_packet(packet);
if(i) printf(" Delay: %d\n", i);
}
#ifdef EMULATOR
u8 telem_bit = rand32() % 7; // random number in [0, 7)
packet[0] = TELEMETRY_ENABLE + telem_bit; // allow emulator to simulate telemetry parsing to prevent future bugs in the telemetry monitor
//printf("telem 1st packet: 0x%x\n", packet[0]);
for(int i = 1; i < 13; i++)
packet[i] = rand32() % 256;
parse_telemetry_packet(packet);
for(int i = 0; i < TELEM_UPDATE_SIZE; i++)
Telemetry.updated[i] = 0xff;
#endif
delay = 320;
txState = 3;
}
if(txState == 3) {
CYRF_SetTxRxMode(TX_EN); //Write mode
if(pkt_num == 0) {
//Keep tx power updated
CYRF_WriteRegister(CYRF_03_TX_CFG, 0x08 | Model.tx_power);
radio_ch_ptr = radio_ch_ptr == &radio_ch[2] ? radio_ch : radio_ch_ptr + 1;
CYRF_ConfigRFChannel(*radio_ch_ptr);
}
txState = 0;
}
return delay;
}
Please Log in or Create an account to join the conversation.
- PhracturedBlue
- Offline
- Posts: 4402
Please Log in or Create an account to join the conversation.
- vlad_vy
- Offline
- Posts: 3333
Please Log in or Create an account to join the conversation.
- Indigo
- Offline
- Posts: 230
devo_cyrf6936.c
//Read telemetry if needed
if (!(CYRF_ReadRegister(CYRF_05_RX_CTRL) & 0x80)) {
// RXGO has cleared so "something" has been received
if (CYRF_ReadDataPacket(packet) == 1) {
...
Please Log in or Create an account to join the conversation.
- Indigo
- Offline
- Posts: 230
vlad_vy wrote: I added CRC16 check for received packet. I don't know if CRC16 check will work with other CYRF protocols. Tested with DEVO and DSMX protocols only.
...
CRC16 check is already included in error bit of RX_IRQ_STATUS but only after receive is complete.
So if RXC=1 and RXE=0, we check RX_IRQ_STATUS again to get final value of RXE which includes CRC16 error.
rx_state = CYRF_ReadRegister(CYRF_07_RX_IRQ_STATUS);
if (rx_state & 0x02) { // receive complete
if (!(rx_state & 0x01)) { // RXC=1, RXE=0 then 2nd check is required (debouncing)
rx_state |= CYRF_ReadRegister(CYRF_07_RX_IRQ_STATUS);
}
Please Log in or Create an account to join the conversation.
- Indigo
- Offline
- Posts: 230
This new version only checks 2 bits: RXE receive data error, and RXC receive complete.
cyrf6936.c
int CYRF_ReadDataPacket(int force, u8 dpbuffer[]) // use "force" if not set RXOW EN in RX_CFG
{
int ok = 0;
u8 rx_state = CYRF_ReadRegister(CYRF_07_RX_IRQ_STATUS);
if (rx_state & 0x01) // RXE=1 bad data
ok = -1;
else if (rx_state & 0x02) // receive complete
// RXC=1, RXE=0 then 2nd check is required (debouncing)
ok = (CYRF_ReadRegister(CYRF_07_RX_IRQ_STATUS) & 0x01) ? -1 : 1;
if (ok == 1 || (ok && force)) {
CYRF_WriteRegister(CYRF_07_RX_IRQ_STATUS, 0x80); // set RXOW before data read
u8 length = CYRF_ReadRegister(CYRF_09_RX_COUNT);
ReadRegisterMulti(CYRF_21_RX_BUFFER, dpbuffer, length);
}
return ok;
}
A new test version 5c9ff36 using the above is available in Test Builds . DSM protocol is using "force" buffer emptying.
Previous test version ee1b869 was all cyrf protocols (DSMx, Devo, J6pro) using buffer overwrite enabled.
Please Log in or Create an account to join the conversation.
- vlad_vy
- Offline
- Posts: 3333
Please Log in or Create an account to join the conversation.
- Home
- Forum
- Development
- Protocol Development
- Support for walkera telemetry.