示例#1
0
文件: odp_uds.c 项目: fkuppens/oobd
void
odp_uds_printdata_Buffer(UBaseType_t msgType, void *data,
			 printChar_cbf printchar)
{
    extern QueueHandle_t inputQueue;

    ODPBuffer **doublePtr;
    ODPBuffer *myUDSBuffer;
    doublePtr = data;
    myUDSBuffer = *doublePtr;
    int i;
    for (i = 0; i < myUDSBuffer->len; i++) {
	printser_uint8ToHex(myUDSBuffer->data[i]);
	if ((i % 8) == 0 && i > 0 && i < myUDSBuffer->len - 1) {
	    printLF();
	}
    }
    if (!((i % 8) == 0 && i > 0 && i < myUDSBuffer->len - 1)) {
	printLF();
    }

    printEOT();
    /* clear the buffer */
    myUDSBuffer->len = 0;
    /* release the input queue */
    if (pdPASS != sendMsg(MSG_SERIAL_RELEASE, inputQueue, NULL)) {
	DEBUGPRINT("FATAL ERROR: input queue is full!\n", "a");
    }

}
示例#2
0
void print_telegram(UBaseType_t msgType, void *data,
		    printChar_cbf printchar)
{
    static data_packet *dp;
    dp = data;
    printser_string("# ");
    printser_int(dp->timestamp * portTICK_PERIOD_MS, 10);
    printser_string(" 0x");
    printser_int(dp->recv, 16);
    printser_string(" 0x");
    printser_int(dp->err, 16);
    printser_string(" ");
    printser_int(dp->len, 10);
    printser_string(" ");
    int i;
    for (i = 0; i < dp->len; i++) {
	printser_uint8ToHex(dp->data[i]);
	printser_string(" ");
    }
    printLF();
}
示例#3
0
void odp_canraw_recvdata(data_packet * p, UBaseType_t callFromISR)
{
    extern print_cbf printdata_CAN;
    extern printChar_cbf printChar;
    extern protocolConfigPtr actProtConfigPtr;
    struct CanRawConfig *protocolConfig;
    short ByteCnt;

    if (callFromISR)
	xTickNew = (uint16_t) xTaskGetTickCountFromISR();
    else
	xTickNew = (uint16_t) xTaskGetTickCount();

    if (xTickNew < xTickOld)	// check for xTick overflow
	xTickOld = 0;

    if (xTickCurrent >= 59999)	// limit timestamp to 0-59999 tick (ms)
	xTickCurrent = 0;

    xTickCurrent = xTickCurrent + (xTickNew - xTickOld);
    xTickOld = xTickNew;	// set latest value to xTickOld for next duration
    p->timestamp = xTickCurrent;

    protocolConfig = actProtConfigPtr;
    if (protocolConfig != NULL) {
	if (protocolConfig->showBusTransfer == 1) {	//normal output
	    MsgData *msg;
	    extern QueueHandle_t protocolQueue;
	    if (NULL != (msg = createDataMsg(p))) {
		UBaseType_t res = 0;
		if (callFromISR) {
		    res = sendMsgFromISR(MSG_BUS_RECV, protocolQueue, msg);
		} else {
		    res = sendMsg(MSG_BUS_RECV, protocolQueue, msg);
		}
		if (res != pdPASS) {
		    disposeMsg(msg);
		    DEBUGPRINT("FATAL ERROR: protocol queue is full!\n",
			       'a');
		}
	    } else {
		DEBUGPRINT("FATAL ERROR: Out of Heap space!l\n", 'a');
	    }
	}
	if (protocolConfig->showBusTransfer == 2) {	//normal output, but straight from the ISR
	    printdata_CAN(MSG_BUS_RECV, p, printChar);
	}
	if (protocolConfig->showBusTransfer == 3) {
	    // Lawicel format: Estimated out of http://lxr.free-electrons.com/source/drivers/net/can/slcan.c line 110 cc.
	    if (p->recv & 0x80000000) {	// Bit 32 set, so it's an extended CAN ID
		printser_string("T");
		printser_uint32ToHex(p->recv & 0x1FFFFFFF);
	    } else {
		printser_string("t");
		printser_int((p->recv & 0x700) >> 8, 10);
		printser_uint8ToHex(p->recv & 0x00FF);
	    }
	    printser_int(p->len, 10);
	    ByteCnt = 0;
	    while (ByteCnt != p->len) {
		printser_uint8ToHex(p->data[ByteCnt]);
		ByteCnt++;
	    }
	    if (p->err == 0x01)
		printser_string("FFFF");	// if error occurs set timestamp to 0xFFFF
	    else
		printser_uint16ToHex(p->timestamp * portTICK_PERIOD_MS & 0xFFFF);	//reduce down to 16 bit = 65536 ms = ~ 1 min
	    printLF();
	}
	if (protocolConfig->showBusTransfer == 4) {
	    printser_uint8ToRaw(255);	//startbyte
	    printser_uint8ToRaw((p->len & 0xF) |	// bit 0-3: DLC
				((p->err & 3) << 4) |	//bit 4-5 : Error flag
				(((p->recv & 0x80000000) ? 1 : 0) << 5)	//bit 6: Extended CAN ID
		);		//Status flag
	    printser_uint16ToRawCoded(p->timestamp * portTICK_PERIOD_MS & 0xFFFF);	//reduce down to 16 bit = 65536 ms = ~ 1 min
	    if ((p->recv & 0x80000000)) {	// Bit 32 set, so it's an exended CAN ID
		printser_uint32ToRawCoded(p->recv & 0x1FFFFFFF);
	    } else {
		printser_uint16ToRawCoded(p->recv & 0x1FFFFFFF);
	    }
	    int i;

	    for (i = 0; i < p->len; i++) {
		printser_uint8ToRawCoded(p->data[i]);
	    }
	}
    }
}