#include #include #include #include #include #define M0 P03 #define M1 P04 #define M2 P01 #define RS485_DIR P05 #define OE P13 #define DS P14 #define SHCP P11 #define STCP P12 #define MAXCMD 64 unsigned char relay; unsigned char crc; unsigned char getchar1(void) { UINT8 c; while (!RI); c = SBUF; RI = 0; return (c); } int putchar1 (unsigned char c) { crc += c; TI = 0; SBUF = c; while(TI==0); return 0; } void sendpkt(unsigned char cmd, unsigned int len, unsigned char *buffer) { unsigned int i; crc = 0; putchar1(0x55); putchar1(0xAA); putchar1(0x03); putchar1(cmd); putchar1(len >> 8); putchar1(len & 0xFF); for (i=0; i