Test an RS485 connection and use the RS485_GUI
PCN-1001 User manual
96
PCN-1001_UserMan_En_4.0
int
main (int argc, char *argv[])
{
char buf[MAX_PACKET_LEN];
char data[6] = {0x73, 0x6c, 0x65, 0x64, 0x00, 0x64};
unsigned char src = 0x01;
unsigned char dest = 0x02;
char tpn = 0x01;
char pn = 0x01;
short datalen = 6;
short crc;
int index = 0;
int data_start;
buf[index++] = 0xFF;
//Preamble
buf[index++] = 0xFF;
//Preamble
buf[index++] = 0xFF;
//Preamble
buf[index++] = 0xFF;
//Preamble
buf[index++] = 0xFF;
//Preamble
buf[index++] = 0x01;
//SOH
data_start = index;
buf[index++] = src;
//source address
buf[index++] = dest;
//destination address
buf[index++] = tpn;
//Total Packet Number
buf[index++] = pn;
//Number of this packet
buf[index++] = datalen & 0x00FF; //Data Length LSB
buf[index++] = datalen >> 8; //Data Length MSB
if(data) memcpy(&buf[index],data,datalen); //Data copied in buf
index += datalen;
CalcCrc16Block(&buf[data_start],6+datalen,&crc);
buf[index++] = crc & 0x00FF; //CRC LSB
buf[index++] = crc >> 8; //CRC MSB
buf[index++] = 0xFF; //Postamble
return 0;
}
Summary of Contents for PCN-1001
Page 1: ...PCN 1001 Passenger People Counter USER MANUAL Rev 4 0 23 December 2011 PCN 1001_UserMan_En_4 0...
Page 13: ...Part 1 Introduction PCN 1001 User manual 13 PCN 1001_UserMan_En_4 0 PART 1 INTRODUCTION...
Page 14: ...This page has been intentionally left blank...
Page 22: ...This page has been intentionally left blank...
Page 32: ...This page has been intentionally left blank...
Page 48: ...This page has been intentionally left blank...
Page 50: ...This page has been intentionally left blank...
Page 97: ...APPENDIX PCN 1001 User manual 97 PCN 1001_UserMan_En_4 0 APPENDIX...
Page 98: ...This page has been intentionally left blank...
Page 110: ...This page has been intentionally left blank...
Page 114: ...This page has been intentionally left blank...
Page 116: ...This page has been intentionally left blank...
Page 117: ...Notes PCN 1001 User manual 117 PCN 1001_UserMan_En_4 0 Notes...