The serial driver 1 (SD1) cant receive data
Posted: Tue Oct 06, 2015 9:55 am
Hi everybody:
SD1 can send data to serial debugging assistant,but cant received the data send from serial debugging assistant. Here is the code i am running:
when I send data to SD1 from serial debugging assistant, why the bytesAvailable always be zero?
thank you very much for your reply.
SD1 can send data to serial debugging assistant,but cant received the data send from serial debugging assistant. Here is the code i am running:
Code: Select all
static WORKING_AREA(waCANThread,4096);
static msg_t CANThread(void *arg)
{
(void)arg;
// EventListener el;
BaseChannel *seri=(BaseChannel *)&SD1;//
static uint8_t smsg[20]={1},*rmsg;
CANRxFrame rxmsg;
uint8_t i=0;
unsigned char txr[8]={0x00,0x11,0x22,0x33,0x44,0x55,0x66,0x77};//
while(1)
{
msg_t result = canReceive(&CAND1, CAN_ANY_MAILBOX, &rxmsg, TIME_IMMEDIATE);
if(result==RDY_OK)
{
if(rxmsg.EID==0x04000001)
{
palTogglePad(GPIOB,9);//
}
}
// palTogglePad(GPIOB, GPIOB_LED_A);
chSysLock();
/* The following function must be called from within a system lock zone. */
size_t bytesAvailable = chnBytesAvailable(seri);
chSysUnlock();
smsg[0]=0;smsg[1]=1;smsg[2]=2;
chnWrite(seri, smsg, 3);
chThdSleepMilliseconds(1000);
if(bytesAvailable)//
{
smsg[0]=bytesAvailable;smsg[1]=1;smsg[2]=2;
chnWrite(seri, smsg, 3);//
palTogglePad(GPIOB,9);
chnRead(seri, rmsg, bytesAvailable);
memcpy(txr,rmsg,bytesAvailable);
palTogglePad(GPIOB,9);
//EID,DATA,LENGTH
CANTransmit(0x04000001,txr,bytesAvailable);//send
chThdSleepMilliseconds(1000);
bytesAvailable=0;
}
}
return 0;
}
when I send data to SD1 from serial debugging assistant, why the bytesAvailable always be zero?
thank you very much for your reply.