wideband on second can (#5108)
This commit is contained in:
parent
fa9fe1754b
commit
12c899ddca
|
@ -39,7 +39,7 @@ static CanTsListener listener;
|
||||||
|
|
||||||
int CanStreamerState::sendFrame(const IsoTpFrameHeader & header, const uint8_t *data, int num, can_sysinterval_t timeout) {
|
int CanStreamerState::sendFrame(const IsoTpFrameHeader & header, const uint8_t *data, int num, can_sysinterval_t timeout) {
|
||||||
int dlc = 8; // standard 8 bytes
|
int dlc = 8; // standard 8 bytes
|
||||||
CanTxMessage txmsg(CanCategory::SERIAL, CAN_ECU_SERIAL_TX_ID, dlc, false);
|
CanTxMessage txmsg(CanCategory::SERIAL, CAN_ECU_SERIAL_TX_ID, dlc, 0, false);
|
||||||
|
|
||||||
// fill the frame data according to the CAN-TP protocol (ISO 15765-2)
|
// fill the frame data according to the CAN-TP protocol (ISO 15765-2)
|
||||||
txmsg[0] = (uint8_t)((header.frameType & 0xf) << 4);
|
txmsg[0] = (uint8_t)((header.frameType & 0xf) << 4);
|
||||||
|
|
|
@ -25,7 +25,13 @@ bool waitAck() {
|
||||||
return chEvtWaitAnyTimeout(EVT_BOOTLOADER_ACK, TIME_MS2I(1000)) != 0;
|
return chEvtWaitAnyTimeout(EVT_BOOTLOADER_ACK, TIME_MS2I(1000)) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static size_t getWidebandBus() {
|
||||||
|
return engineConfiguration->widebandOnSecondBus ? 1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
void updateWidebandFirmware() {
|
void updateWidebandFirmware() {
|
||||||
|
size_t bus = getWidebandBus();
|
||||||
|
|
||||||
// Clear any pending acks for this thread
|
// Clear any pending acks for this thread
|
||||||
chEvtGetAndClearEvents(EVT_BOOTLOADER_ACK);
|
chEvtGetAndClearEvents(EVT_BOOTLOADER_ACK);
|
||||||
|
|
||||||
|
@ -43,7 +49,7 @@ void updateWidebandFirmware() {
|
||||||
for (int i = 0; i < 2; i++) {
|
for (int i = 0; i < 2; i++) {
|
||||||
{
|
{
|
||||||
// Send bootloader entry command
|
// Send bootloader entry command
|
||||||
CanTxMessage m(CanCategory::WBO_SERVICE, 0xEF0'0000, 0, true);
|
CanTxMessage m(CanCategory::WBO_SERVICE, 0xEF0'0000, 0, bus, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!waitAck()) {
|
if (!waitAck()) {
|
||||||
|
@ -59,7 +65,7 @@ void updateWidebandFirmware() {
|
||||||
|
|
||||||
{
|
{
|
||||||
// Erase flash - opcode 1, magic value 0x5A5A
|
// Erase flash - opcode 1, magic value 0x5A5A
|
||||||
CanTxMessage m(CanCategory::WBO_SERVICE, 0xEF1'5A5A, 0, true);
|
CanTxMessage m(CanCategory::WBO_SERVICE, 0xEF1'5A5A, 0, bus, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!waitAck()) {
|
if (!waitAck()) {
|
||||||
|
@ -74,7 +80,7 @@ void updateWidebandFirmware() {
|
||||||
// Send flash data 8 bytes at a time
|
// Send flash data 8 bytes at a time
|
||||||
for (size_t i = 0; i < totalSize; i += 8) {
|
for (size_t i = 0; i < totalSize; i += 8) {
|
||||||
{
|
{
|
||||||
CanTxMessage m(CanCategory::WBO_SERVICE, 0xEF2'0000 + i, 8, true);
|
CanTxMessage m(CanCategory::WBO_SERVICE, 0xEF2'0000 + i, 8, bus, true);
|
||||||
memcpy(&m[0], build_wideband_image_bin + i, 8);
|
memcpy(&m[0], build_wideband_image_bin + i, 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +94,7 @@ void updateWidebandFirmware() {
|
||||||
|
|
||||||
{
|
{
|
||||||
// Reboot to firmware!
|
// Reboot to firmware!
|
||||||
CanTxMessage m(CanCategory::WBO_SERVICE, 0xEF3'0000, 0, true);
|
CanTxMessage m(CanCategory::WBO_SERVICE, 0xEF3'0000, 0, bus, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
waitAck();
|
waitAck();
|
||||||
|
@ -109,7 +115,7 @@ void setWidebandOffset(uint8_t index) {
|
||||||
efiPrintf("Setting all connected widebands to index %d...", index);
|
efiPrintf("Setting all connected widebands to index %d...", index);
|
||||||
|
|
||||||
{
|
{
|
||||||
CanTxMessage m(CanCategory::WBO_SERVICE, 0xEF4'0000, 1, true);
|
CanTxMessage m(CanCategory::WBO_SERVICE, 0xEF4'0000, 1, getWidebandBus(), true);
|
||||||
m[0] = index;
|
m[0] = index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,7 +127,7 @@ void setWidebandOffset(uint8_t index) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void sendWidebandInfo() {
|
void sendWidebandInfo() {
|
||||||
CanTxMessage m(CanCategory::WBO_SERVICE, 0xEF5'0000, 2, true);
|
CanTxMessage m(CanCategory::WBO_SERVICE, 0xEF5'0000, 2, getWidebandBus(), true);
|
||||||
|
|
||||||
float vbatt = Sensor::getOrZero(SensorType::BatteryVoltage) * 10;
|
float vbatt = Sensor::getOrZero(SensorType::BatteryVoltage) * 10;
|
||||||
|
|
||||||
|
|
|
@ -174,7 +174,7 @@ static int lua_txCan(lua_State* l) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// conform ext parameter to true/false
|
// conform ext parameter to true/false
|
||||||
CanTxMessage msg(CanCategory::LUA, id, 8, ext == 0 ? false : true);
|
CanTxMessage msg(CanCategory::LUA, id, 8, 0, ext == 0 ? false : true);
|
||||||
msg.busIndex = bus;
|
msg.busIndex = bus;
|
||||||
|
|
||||||
// Unfortunately there is no way to inspect the length of a table,
|
// Unfortunately there is no way to inspect the length of a table,
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
}
|
}
|
||||||
#endif // EFI_CAN_SUPPORT
|
#endif // EFI_CAN_SUPPORT
|
||||||
|
|
||||||
CanTxMessage::CanTxMessage(CanCategory category, uint32_t eid, uint8_t dlc, bool isExtended) {
|
CanTxMessage::CanTxMessage(CanCategory category, uint32_t eid, uint8_t dlc, size_t bus, bool isExtended) {
|
||||||
this->category = category;
|
this->category = category;
|
||||||
#if HAL_USE_CAN || EFI_UNIT_TEST
|
#if HAL_USE_CAN || EFI_UNIT_TEST
|
||||||
#ifndef STM32H7XX
|
#ifndef STM32H7XX
|
||||||
|
@ -43,6 +43,8 @@ CanTxMessage::CanTxMessage(CanCategory category, uint32_t eid, uint8_t dlc, bool
|
||||||
|
|
||||||
setDlc(dlc);
|
setDlc(dlc);
|
||||||
|
|
||||||
|
setBus(0);
|
||||||
|
|
||||||
memset(m_frame.data8, 0, sizeof(m_frame.data8));
|
memset(m_frame.data8, 0, sizeof(m_frame.data8));
|
||||||
#endif // HAL_USE_CAN || EFI_UNIT_TEST
|
#endif // HAL_USE_CAN || EFI_UNIT_TEST
|
||||||
}
|
}
|
||||||
|
@ -92,6 +94,10 @@ void CanTxMessage::setDlc(uint8_t dlc) {
|
||||||
m_frame.DLC = dlc;
|
m_frame.DLC = dlc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CanTxMessage::setBus(size_t bus) {
|
||||||
|
busIndex = bus;
|
||||||
|
}
|
||||||
|
|
||||||
void CanTxMessage::setShortValue(uint16_t value, size_t offset) {
|
void CanTxMessage::setShortValue(uint16_t value, size_t offset) {
|
||||||
m_frame.data8[offset] = value & 0xFF;
|
m_frame.data8[offset] = value & 0xFF;
|
||||||
m_frame.data8[offset + 1] = value >> 8;
|
m_frame.data8[offset + 1] = value >> 8;
|
||||||
|
|
|
@ -29,7 +29,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* Create a new CAN message, with the specified extended ID.
|
* Create a new CAN message, with the specified extended ID.
|
||||||
*/
|
*/
|
||||||
explicit CanTxMessage(CanCategory category, uint32_t eid, uint8_t dlc = 8, bool isExtended = false);
|
explicit CanTxMessage(CanCategory category, uint32_t eid, uint8_t dlc = 8, size_t bus = 0, bool isExtended = false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destruction of an instance of CanTxMessage will transmit the message over the wire.
|
* Destruction of an instance of CanTxMessage will transmit the message over the wire.
|
||||||
|
@ -64,6 +64,8 @@ public:
|
||||||
|
|
||||||
void setDlc(uint8_t dlc);
|
void setDlc(uint8_t dlc);
|
||||||
|
|
||||||
|
void setBus(size_t bus);
|
||||||
|
|
||||||
#if HAL_USE_CAN || EFI_UNIT_TEST
|
#if HAL_USE_CAN || EFI_UNIT_TEST
|
||||||
const CANTxFrame *getFrame() const {
|
const CANTxFrame *getFrame() const {
|
||||||
return &m_frame;
|
return &m_frame;
|
||||||
|
|
|
@ -1014,7 +1014,7 @@ end_struct
|
||||||
uint16_t tps2SecondaryMin;;"ADC", 1, 0, 0, 1000, 0
|
uint16_t tps2SecondaryMin;;"ADC", 1, 0, 0, 1000, 0
|
||||||
uint16_t tps2SecondaryMax;;"ADC", 1, 0, 0, 1000, 0
|
uint16_t tps2SecondaryMax;;"ADC", 1, 0, 0, 1000, 0
|
||||||
|
|
||||||
bit unusedBitDisablePrimaryUart
|
bit widebandOnSecondBus,"2","1";Select which bus the wideband controller is attached to.
|
||||||
bit fuelClosedLoopCorrectionEnabled;Enables lambda sensor closed loop feedback for fuelling.
|
bit fuelClosedLoopCorrectionEnabled;Enables lambda sensor closed loop feedback for fuelling.
|
||||||
bit isVerboseIAC;Print details into rusEFI console\nenable verbose_idle
|
bit isVerboseIAC;Print details into rusEFI console\nenable verbose_idle
|
||||||
bit boardUseTachPullUp,"12v","5v"
|
bit boardUseTachPullUp,"12v","5v"
|
||||||
|
|
|
@ -4109,6 +4109,7 @@ dialog = tcuControls, "Transmission Settings"
|
||||||
field = "!Disconnect all controllers you don't want to set!"
|
field = "!Disconnect all controllers you don't want to set!"
|
||||||
commandButton = "Set Index 0", cmd_set_wideband_idx_0
|
commandButton = "Set Index 0", cmd_set_wideband_idx_0
|
||||||
commandButton = "Set Index 1", cmd_set_wideband_idx_1
|
commandButton = "Set Index 1", cmd_set_wideband_idx_1
|
||||||
|
field = "Wideband CAN bus", widebandOnSecondBus
|
||||||
field = "Force O2 sensor heating", forceO2Heating
|
field = "Force O2 sensor heating", forceO2Heating
|
||||||
|
|
||||||
dialog = engineTypeDialog, "Popular vehicles"
|
dialog = engineTypeDialog, "Popular vehicles"
|
||||||
|
|
Loading…
Reference in New Issue