Added Transmission Sucess
This commit is contained in:
@@ -68,17 +68,3 @@ void GobotRPC_CI::heartBeartTaskFn() {
|
||||
vTaskDelay(GOBOTRPC_HEARTBEAT_INTERVAL / portTICK_PERIOD_MS);
|
||||
}
|
||||
}
|
||||
|
||||
void GobotRPC_CI::send_ErrorTransmission(bool rx, uint64_t addr) {
|
||||
char errorPacket[7];
|
||||
|
||||
errorPacket[0] = ERROR_TRANMISSION;
|
||||
errorPacket[1] = 7;
|
||||
errorPacket[2] = rx ? 0x01 : 0x00;
|
||||
errorPacket[3] = (addr >> 24) & 0xff;
|
||||
errorPacket[4] = (addr >> 16) & 0xff;
|
||||
errorPacket[5] = (addr >> 8) & 0xff;
|
||||
errorPacket[6] = addr & 0xff;
|
||||
|
||||
this->hardware->send(errorPacket, 7);
|
||||
}
|
||||
@@ -17,11 +17,44 @@ void GobotRPC_CI::txCIInstructionTask() {
|
||||
xQueueReceive(ciInstructionQueue, &ciInstruction, portMAX_DELAY);
|
||||
|
||||
switch (ciInstruction.type) {
|
||||
case CI_INSTRUCTION_SEND_TRANMISSION_ERROR:
|
||||
uint32_t addr = ciInstruction.data[1] | (ciInstruction.data[2] << 8) | (ciInstruction.data[3] << 16) | (ciInstruction.data[4] << 24);
|
||||
uint8_t rx = ciInstruction.data[0];
|
||||
send_ErrorTransmission(rx, addr);
|
||||
break;
|
||||
case CI_INSTRUCTION_SEND_TRANMISSION_ERROR: {
|
||||
uint32_t addr = ciInstruction.data[1] | (ciInstruction.data[2] << 8) | (ciInstruction.data[3] << 16) | (ciInstruction.data[4] << 24);
|
||||
uint8_t rx = ciInstruction.data[0];
|
||||
send_ErrorTransmission(rx, addr);
|
||||
break;
|
||||
}
|
||||
case CI_INSTRUCTION_SEND_TRANMISSION_SUCCESS: {
|
||||
uint32_t addr = ciInstruction.data[1] | (ciInstruction.data[2] << 8) | (ciInstruction.data[3] << 16) | (ciInstruction.data[4] << 24);
|
||||
send_SuccessTransmission(addr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GobotRPC_CI::send_ErrorTransmission(bool rx, uint64_t addr) {
|
||||
char errorPacket[7];
|
||||
|
||||
errorPacket[0] = ERROR_TRANMISSION;
|
||||
errorPacket[1] = 7;
|
||||
errorPacket[2] = rx ? 0x01 : 0x00;
|
||||
errorPacket[3] = (addr >> 24) & 0xff;
|
||||
errorPacket[4] = (addr >> 16) & 0xff;
|
||||
errorPacket[5] = (addr >> 8) & 0xff;
|
||||
errorPacket[6] = addr & 0xff;
|
||||
|
||||
this->hardware->send(errorPacket, 7);
|
||||
}
|
||||
|
||||
void GobotRPC_CI::send_SuccessTransmission(uint64_t addr) {
|
||||
char successPacket[6];
|
||||
|
||||
successPacket[0] = SUCESS_TRANMISSION;
|
||||
successPacket[1] = 6;
|
||||
successPacket[2] = (addr >> 24) & 0xff;
|
||||
successPacket[3] = (addr >> 16) & 0xff;
|
||||
successPacket[4] = (addr >> 8) & 0xff;
|
||||
successPacket[5] = addr & 0xff;
|
||||
|
||||
this->hardware->send(successPacket, 6);
|
||||
}
|
||||
@@ -7,6 +7,7 @@ enum GobotRPC_CI_CMD {
|
||||
RX_CI_PACKET = 0x02,
|
||||
PERFORM_SCAN_CI_PACKET = 0x03,
|
||||
SCAN_RESULT_CI_PACKET = 0x04,
|
||||
SUCESS_TRANMISSION = 0xfc,
|
||||
ERROR_TRANMISSION = 0xfd,
|
||||
HEARTBEAT = 0xff
|
||||
};
|
||||
@@ -46,4 +47,5 @@ public:
|
||||
// CI Instruction Stuff
|
||||
void txCIInstructionTask();
|
||||
void send_ErrorTransmission(bool rx, uint64_t addr);
|
||||
void send_SuccessTransmission(uint64_t addr);
|
||||
};
|
||||
@@ -1,5 +1,6 @@
|
||||
enum CI_Instruction_Type {
|
||||
CI_INSTRUCTION_SEND_TRANMISSION_ERROR
|
||||
CI_INSTRUCTION_SEND_TRANMISSION_ERROR,
|
||||
CI_INSTRUCTION_SEND_TRANMISSION_SUCCESS
|
||||
};
|
||||
|
||||
struct CI_Instruction_Transport {
|
||||
|
||||
@@ -77,6 +77,7 @@ public:
|
||||
uint32_t readIntPins();
|
||||
|
||||
void raiseTranmissionError(bool rx, uint32_t addr);
|
||||
void raiseTransmissionSuceess(uint32_t addr);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -12,5 +12,16 @@ void GobotRPC_TI_Hardware_RP2040_I2C::raiseTranmissionError(bool rx, uint32_t ad
|
||||
ciInstruction.data[3] = (addr >> 16) & 0xff;
|
||||
ciInstruction.data[4] = (addr >> 24) & 0xff;
|
||||
|
||||
this->pushCIInstructionCB(&ciInstruction, pushCIInstructionCBArgs);
|
||||
}
|
||||
|
||||
void GobotRPC_TI_Hardware_RP2040_I2C::raiseTransmissionSuceess(uint32_t addr) {
|
||||
CI_Instruction_Transport ciInstruction;
|
||||
ciInstruction.type = CI_INSTRUCTION_SEND_TRANMISSION_SUCCESS;
|
||||
ciInstruction.data[0] = addr & 0xff;
|
||||
ciInstruction.data[1] = (addr >> 8) & 0xff;
|
||||
ciInstruction.data[2] = (addr >> 16) & 0xff;
|
||||
ciInstruction.data[3] = (addr >> 24) & 0xff;
|
||||
|
||||
this->pushCIInstructionCB(&ciInstruction, pushCIInstructionCBArgs);
|
||||
}
|
||||
@@ -20,8 +20,10 @@ void GobotRPC_TI_Hardware_RP2040_I2C::i2cTxTask() {
|
||||
unsigned int res = i2c_write_burst_blocking(i2c, pkg.addr & 0x7f, (uint8_t *)(&pkg.data), pkg.len);
|
||||
xSemaphoreGive(i2cMutex);
|
||||
|
||||
if(res == PICO_ERROR_GENERIC) {
|
||||
if(res != PICO_ERROR_GENERIC) {
|
||||
raiseTranmissionError(false, pkg.addr);
|
||||
} else {
|
||||
raiseTransmissionSuceess(pkg.addr);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user