pros
pros copied to clipboard
🐛Address Vex Radio Port Claim Issues
Summary:
Remove _link_init wrapper and add a check + kprintf warning for when the user attempts to use multiple radios on one brain
Motivation:
For now we'll officially support one radio per brain same as VEXcode.
References (optional):
Related to the issue in PR #360
Test Plan:
- [ ] Run on hardware with one radio to verify that it functions as usual
- [ ] Run on hardware with two radios to verify that warning is presented on kernel debug
Test code for receiver radio and transmitting radio (include pros/apix.h for both)
#define RX_LINK_PORT 10
char buf[100];
void opcontrol() {
//init
int success = pros::c::link_init_override(RX_LINK_PORT, "test", pros::E_LINK_RECIEVER);
pros::lcd::print(1, "Radio init: %d\n",success);
while (true) {
pros::lcd::print(2, "Plugged type: %d",\
pros::c::registry_get_plugged_type(RX_LINK_PORT - 1));
pros::lcd::print(3, "Bound type: %d",\
pros::c::registry_get_bound_type(RX_LINK_PORT - 1));
if(pros::c::link_raw_receivable_size(RX_LINK_PORT) > 0) {
pros::lcd::clear_line(0);
printf("Readable Size Actual: %d\n", pros::c::link_raw_receivable_size(RX_LINK_PORT));
pros::c::link_receive(RX_LINK_PORT, buf, 10);
printf("Msg: %s", buf);
pros::lcd::print(0, "Recieved Message: %s", buf);
}
pros::lcd::print(4, "RX Connected?: %d", pros::c::link_connected(RX_LINK_PORT));
pros::lcd::print(5, "RX Size: %d", pros::c::link_raw_receivable_size(RX_LINK_PORT));
pros::lcd::print(6, "Errno: %d", errno); // ENODEV
pros::delay(2000);
}
}
#define TX_LINK_PORT 1
char msg[10] = "TEST_MSG1";
void opcontrol() {
int success = pros::c::link_init_override(TX_LINK_PORT, "test", pros::E_LINK_TRANSMITTER);
pros::lcd::print(1, "Radio init: %d\n",success);
while (true) {
pros::lcd::print(2, "Plugged type: %d",\
pros::c::registry_get_plugged_type(TX_LINK_PORT - 1));
pros::lcd::print(3, "Bound type: %d",\
pros::c::registry_get_bound_type(TX_LINK_PORT - 1));
pros::c::link_transmit(TX_LINK_PORT, msg, 10);
pros::lcd::print(4, "TX Connected?: %d", pros::c::link_connected(TX_LINK_PORT));
pros::lcd::print(5, "TX Size: %d", pros::c::link_raw_transmittable_size(TX_LINK_PORT));
pros::lcd::print(6, "Errno: %d", errno); // ENODEV
pros::delay(2000);
}
}