C2k 团队、
我试图对一些设备进行 LIN MITM 攻击、并尝试为 LIN 外设编写一些驱动程序。 似乎没有任何文件或示例说明如何推动奴隶的响应。 我唯一能找到的是:
在此处发布的示例中、用户只能响应单个 ID。 该示例还告诉我、底层状态机希望在允许从器件响应之前看到 TX ID 匹配吗? 这是真的吗?
我正在尝试编写一个基于中断的驱动程序、在该驱动程序中、我管理与处理器的所有通信、不使用任何滤波/屏蔽。 我能够全天接收消息。 当我获得用于从器件响应消息的 ID 中断时、我将数据复制到 TX 缓冲区、但始终不会被发送出去、并且首次运行后、isTxReady 检查失败。
这是我的 ISR:
__interrupt void
LIN_linAHandler(void)
{
uint16_t interruptCause;
//
// Read the high priority interrupt vector
//
interruptCause = LIN_getInterruptLine0Offset(LINA_BASE);
switch(interruptCause)
{
case LIN_VECT_ID:
{
linMessageObject_t *message;
volatile uint16_t messageId;
messageId = LIN_getRxIdentifier(LINA_BASE);
message = LIN_linGetMessageObjectById(messageId);
if(message != 0)
{
//Set frame length so it may be received correctly
LIN_setFrameLength(LINA_BASE, message->len);
//Calculate period
// message->period = timer0getCount() - message->lastRxTime;
// message->lastRxTime = timer0getCount();
//If the message is TX its showtime baybee!
if((message->direction == LINMESSAGE_TO_MASTER) && injectionActive)
{
// LIN_linTx(LINA_BASE, message);
if(LIN_isTxReady(LINA_BASE))
{
//
// Write data to Tx Buffer of LINA
//
LIN_sendData(LINA_BASE, message->originalData);
}
}
//If the message is RX we are done
}
//Clear Interrupt Status
LIN_clearInterruptStatus(LINA_BASE, LIN_INT_ID);
break;
}
case LIN_VECT_RX:
{
linMessageObject_t *message;
volatile uint16_t dumpBuffer[8];
message = LIN_linGetMessageObjectById(LIN_getRxIdentifier(LINA_BASE));
if(message != 0)
{
if((message->direction == LINMESSAGE_TO_SLAVE) )//|| !injectionActive)
{
LIN_getData(LINA_BASE, message->originalData);
}else
{
//We gots a problem
//Data in the rx buffer we don't know what to do with.
// ESTOP0;
LIN_getData(LINA_BASE, dumpBuffer);
}
}else
{
LIN_getData(LINA_BASE, dumpBuffer);
}
LIN_clearInterruptStatus(LINA_BASE, LIN_INT_RX);
break;
}
case LIN_VECT_TX:
{
LIN_clearInterruptStatus(LINA_BASE, LIN_INT_TX);
break;
}
case LIN_VECT_CE:
{
LIN_clearInterruptStatus(LINA_BASE, LIN_INT_CE);
// ESTOP0;
break;
}
case LIN_VECT_FE:
{
LIN_clearInterruptStatus(LINA_BASE, LIN_INT_FE);
// ESTOP0;
break;
}
case LIN_VECT_OE:
{
LIN_clearInterruptStatus(LINA_BASE, LIN_INT_OE);
// ESTOP0;
break;
}
case LIN_VECT_BE:
{
LIN_clearInterruptStatus(LINA_BASE, LIN_INT_BE);
// ESTOP0;
break;
}
case LIN_VECT_NRE:
{
LIN_clearInterruptStatus(LINA_BASE, LIN_INT_NRE);
// ESTOP0;
break;
}
case LIN_VECT_PBE:
{
LIN_clearInterruptStatus(LINA_BASE, LIN_INT_PBE);
// ESTOP0;
break;
}
default:
ESTOP0;
}
LIN_clearGlobalInterruptStatus(LINA_BASE, LIN_INTERRUPT_LINE0);
//
// Acknowledge this interrupt located in group 8
//
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP8);
}
有什么想法我做错了? 当这样的关键功能没有记录下来并且没有示例时、这是非常令人沮丧的。 μ s