I need to now the byteslength in ncRead

I use nationals PCI CAN and had created a Read and Write Frame API in Visual c++. When I read the Can bus I got the hole message and everything is fine. The problem is that the can bus I read from send message with different byte lengths and I need to now how many bytes there is in every message? I now that this information is in the messages Frame but I can´t get it. Please help me!
//Olssoninc

Here is my CAN read/write function!
void CCaNREADERView::ReadCAN(unsigned char *byte,char *cReadId,char *cWriteId)
 char csCANStdWrite[14]="CAN1:TD";
 strcat_s(csCANStdWrite,14,cWriteId);
 char csCANStdRead[14]="CAN1:TD";
 strcat_s(csCANStdRead,14,cReadId);
 NCTYPE_STATUS           Status;
 NCTYPE_STATE            State;
 NCTYPE_CAN_DATA         Transmit;
 NCTYPE_CAN_STRUCT Receive;
 NCTYPE_ATTRID           AttrIdList[8];
 NCTYPE_UINT32           AttrValueList[8];
   AttrIdList[0] =         NC_ATTR_BAUD_RATE;  
   AttrValueList[0] =      50000;
   AttrIdList[1] =         NC_ATTR_START_ON_OPEN;
   AttrValueList[1] =      NC_TRUE;
   AttrIdList[2] =         NC_ATTR_READ_Q_LEN;
   AttrValueList[2] =      0;
   AttrIdList[3] =         NC_ATTR_WRITE_Q_LEN;
   AttrValueList[3] =      0;
   AttrIdList[4] =         NC_ATTR_CAN_COMP_STD;
   AttrValueList[4] =    NC_CAN_ARBID_NONE;
   AttrIdList[5] =         NC_ATTR_CAN_MASK_STD;
   AttrValueList[5] =      NC_CAN_MASK_STD_DONTCARE;
   AttrIdList[6] =         NC_ATTR_CAN_COMP_XTD;
   AttrValueList[6] =      NC_CAN_ARBID_NONE;
   AttrIdList[7] =         NC_ATTR_CAN_MASK_XTD;
   AttrValueList[7] =      NC_CAN_MASK_XTD_DONTCARE;
   Status = ncConfig("CAN0", 8, AttrIdList, AttrValueList);
   PrintStat(Status, "ncConfig CAN0"); 
   Status = ncConfig("CAN1", 8, AttrIdList, AttrValueList);
   PrintStat(Status, "ncConfig CAN1"); 
   AttrIdList[0] =         NC_ATTR_COMM_TYPE;
   AttrValueList[0] =      NC_CAN_COMM_RX_PERIODIC;//NC_CAN_COMM_RX_UNSOL;
   AttrIdList[1] =         NC_ATTR_PERIOD;
   AttrValueList[1] =      NC_DURATION_10SEC;
 AttrIdList[2] =         NC_ATTR_CAN_DATA_LENGTH;
 AttrValueList[2] =      3;
   AttrIdList[3] =         NC_ATTR_CAN_TX_RESPONSE;  
   AttrValueList[3] =      NC_FALSE;
   AttrIdList[4] =         NC_ATTR_RX_CHANGES_ONLY;
   AttrValueList[4] =      NC_FALSE;
   AttrIdList[5] =         NC_ATTR_READ_Q_LEN;
   AttrValueList[5] =      0;
   AttrIdList[6] =         NC_ATTR_WRITE_Q_LEN;
   AttrValueList[6] =      0;
   Status = ncConfig(csCANStdRead, 7, AttrIdList, AttrValueList);
   PrintStat(Status, "ncConfig CAN0::1224 (receiving)"); 
   AttrIdList[0] =         NC_ATTR_COMM_TYPE;
   AttrValueList[0] =      NC_CAN_COMM_TX_PERIODIC;
   AttrIdList[1] =         NC_ATTR_BKD_PERIOD;
   AttrValueList[1] =      NC_DURATION_1SEC;
   AttrIdList[2] =         NC_ATTR_CAN_DATA_LENGTH;
   AttrValueList[2] =     7;  //Length of Transmitting mes
   AttrIdList[3] =         NC_ATTR_CAN_TX_RESPONSE;  
   AttrValueList[3] =      NC_FALSE;
   AttrIdList[4] =   NC_ATTR_RX_CHANGES_ONLY;
   AttrValueList[4] =  NC_FALSE;
 AttrIdList[5] =         NC_ATTR_READ_Q_LEN;
 AttrValueList[5] =      0;
 AttrIdList[6] =         NC_ATTR_WRITE_Q_LEN;
 AttrValueList[6] =      0;
 Status = ncConfig(csCANStdWrite, 7, AttrIdList, AttrValueList);
 PrintStat(Status, "ncConfig CAN1::1224 (transmitting)"); 
 Status = ncOpenObject(csCANStdRead, &RxHandle);
 PrintStat(Status, "ncOpenObject CAN0::1224 (receiving)");
 Status = ncOpenObject(csCANStdWrite, &TxHandle);
 PrintStat(Status, "ncOpenObject CAN1:TD1224 (transmitting)");
 Transmit.Data[0] = 0x00;
 Transmit.Data[1] = 0x00;
 Transmit.Data[2] = 0x00;
 Transmit.Data[3] = 0x00;
 Transmit.Data[4] = 0x00;
 Transmit.Data[5] = 0x00;
 Transmit.Data[6] = 0x00;
 Transmit.Data[7] = 0x00;
 Status= ncWrite(TxHandle, sizeof(Transmit), &Transmit);
 PrintStat(Status, "ncWrite");
     Status = ncWaitForState(RxHandle,
               (NC_ST_READ_AVAIL | NC_ST_ERROR),
               (NC_DURATION_10SEC * 2), &State);
 PrintStat(Status, "ncWaitForState");
 Status= ncRead(RxHandle, sizeof(Receive), &Receive);
 for(int i=0;i<8;i++)
  byte[i]=Receive.Data[i];
 Status = ncCloseObject(TxHandle);
 PrintStat(Status, "ncCloseObject CAN1:TD5 (transmitting object)");
 Status = ncCloseObject(RxHandle);
 PrintStat(Status, "ncCloseObject CAN0:TD5 (receiving object)");

Similar Messages

Maybe you are looking for