|
@@ -42,11 +42,33 @@ struct Address Addr={0x01,0x02,0x03,0x05,0x06,0xFF};
|
|
|
struct Command Cmd={0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x24,0x27,0x28,0x29,0x2C,0x81,0x83,
|
|
|
0x85,0x86,0x87,0x88,0x089,0x8A,0x8B,0x8C,0x90,0x93,0xe0,0xe1,0xe2,0xe3};
|
|
|
|
|
|
+int tranceiveRelDelayTime(int fd, unsigned char* cmd, unsigned char cmd_len, unsigned char* rx, unsigned short _delay)
|
|
|
+{
|
|
|
+ int len;
|
|
|
+ //sleep(2); //required to make flush work, for some reason
|
|
|
+ tcflush(fd,TCIOFLUSH);
|
|
|
+
|
|
|
+ if(write(fd, cmd, cmd_len) >= cmd_len)
|
|
|
+ {
|
|
|
+ usleep(_delay * 1000);
|
|
|
+ len = read(fd, rx, 512);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ #ifdef SystemLogMessage
|
|
|
+ DEBUG_ERROR("Serial command %s response fail.\n", cmd);
|
|
|
+ #endif
|
|
|
+ }
|
|
|
+
|
|
|
+ return len;
|
|
|
+}
|
|
|
+
|
|
|
int tranceive(int fd, unsigned char* cmd, unsigned char cmd_len, unsigned char* rx)
|
|
|
{
|
|
|
int len;
|
|
|
//sleep(2); //required to make flush work, for some reason
|
|
|
tcflush(fd,TCIOFLUSH);
|
|
|
+
|
|
|
if(write(fd, cmd, cmd_len) >= cmd_len)
|
|
|
{
|
|
|
usleep(15000);
|