HAIL TO THE KING! Finally Fixed Transmisson BUG!

This commit is contained in:
2026-01-04 01:46:25 +01:00
parent c36e9053c4
commit 2c9e9be6b3
3 changed files with 17 additions and 105 deletions

View File

@@ -135,19 +135,28 @@ BCDriver::DriverStateResult BCDriverTinyCan::setConsoleSlaveMode()
{
uint32_t console = static_cast<uint32_t>(BCDevice::ID::Console);
uint8_t slaveFlag = static_cast<uint8_t>(BC::ID::Cons_Status_Slave);
uint8_t slaveFlag = static_cast<uint8_t> (BC::ID::Cons_Status_Slave);
qDebug() << "XXX BCDriverTinyCan::Driver Init: putting Console in slave mode ... ";
// Console already in slave mode. good!
if( readRawByte( console, slaveFlag ) )
return DriverState::DeviceReady;
TransmitResult isSlave = 0;
// Already slave?
isSlave = readRawByte( console, slaveFlag );
if( isSlave.has_value() )
{
qDebug() << "Console responded: " << isSlave.value();
if( isSlave.value() == 1 )
{
qDebug() << "Console already in slave mode. good!";
return DriverState::DeviceReady;
}
}
qDebug() << "BCDriverTinyCan::BCDriverTinyCan::XXX Driver Init: putting Console in slave mode ... ";
unsigned int retry = cTimeOuts;
TransmitResult isSlave = 0;
do
{
writeRawByte( console, slaveFlag, 1 );
@@ -222,12 +231,13 @@ retry:
if ((err = CanReceive(0, &msg, 1)) > 0)
{
if (--retry && (msg.Id != BIB || msg.MsgLen != 4 || msg.MsgData[1] != reg))
qDebug() << " retry: " << retry << " BIB:" << BC::ID::ID_Bib << " msg.Id: " << msg.Id << " msg.MsgLen: " << msg.MsgLen << " msg.MsgData[1]: " << msg.MsgData[1] << " reg: " << reg;
if (--retry && (msg.Id != (uint32_t)BC::ID::ID_Bib|| msg.MsgLen != 4 || msg.MsgData[1] != reg))
goto retry;
if (!retry)
{
qDebug() << "XXX error: no response from node";
qDebug() << "XXX error: no response from node: " << err;
return 0;
}
qDebug() << " --- CAN Read Byte: Device: "<< deviceID << " register: " << registerID << " BYTE: " << (uint32_t) msg.MsgData[3];