Second CAN #3687
This commit is contained in:
parent
b6a8bed429
commit
4ad1f887fd
|
@ -158,7 +158,7 @@ static uint32_t getArray(lua_State* l, int paramIndex, uint8_t *data, uint32_t s
|
|||
static int lua_txCan(lua_State* l) {
|
||||
auto channel = luaL_checkinteger(l, 1);
|
||||
// TODO: support multiple channels
|
||||
luaL_argcheck(l, channel == 1, 1, "only channel 1 currently supported");
|
||||
luaL_argcheck(l, channel == 1 || channel == 2, 1, "only channels 1 and 2 currently supported");
|
||||
|
||||
auto id = luaL_checkinteger(l, 2);
|
||||
auto ext = luaL_checkinteger(l, 3);
|
||||
|
@ -172,6 +172,7 @@ static int lua_txCan(lua_State* l) {
|
|||
|
||||
// conform ext parameter to true/false
|
||||
CanTxMessage msg(id, 8, ext == 0 ? false : true);
|
||||
msg.busIndex = channel - HUMAN_OFFSET;
|
||||
|
||||
// Unfortunately there is no way to inspect the length of a table,
|
||||
// so we have to just iterate until we run out of numbers
|
||||
|
|
|
@ -48,7 +48,7 @@ CanTxMessage::CanTxMessage(uint32_t eid, uint8_t dlc, bool isExtended) {
|
|||
|
||||
CanTxMessage::~CanTxMessage() {
|
||||
#if EFI_CAN_SUPPORT
|
||||
auto device = s_devices[0];
|
||||
auto device = s_devices[busIndex];
|
||||
|
||||
if (!device) {
|
||||
warning(CUSTOM_ERR_CAN_CONFIGURATION, "CAN configuration issue");
|
||||
|
@ -60,7 +60,9 @@ CanTxMessage::~CanTxMessage() {
|
|||
}
|
||||
|
||||
if (engineConfiguration->verboseCan) {
|
||||
efiPrintf("Sending CAN message: SID %x/%x %x %x %x %x %x %x %x %x", CAN_SID(m_frame), m_frame.DLC,
|
||||
efiPrintf("Sending CAN bus%d message: SID %x/%x %x %x %x %x %x %x %x %x",
|
||||
busIndex,
|
||||
CAN_SID(m_frame), m_frame.DLC,
|
||||
m_frame.data8[0], m_frame.data8[1],
|
||||
m_frame.data8[2], m_frame.data8[3],
|
||||
m_frame.data8[4], m_frame.data8[5],
|
||||
|
|
|
@ -42,6 +42,9 @@ public:
|
|||
*/
|
||||
static void setDevice(CANDriver* device1, CANDriver* device2);
|
||||
#endif // EFI_CAN_SUPPORT
|
||||
|
||||
size_t busIndex = 0;
|
||||
|
||||
/**
|
||||
* @brief Read & write the raw underlying 8-byte buffer.
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue