44 #define SEND_PORT 6554 |
44 #define SEND_PORT 6554 |
45 |
45 |
46 |
46 |
47 struct sockaddr_in sendaddr; /* Server send socket */ |
47 struct sockaddr_in sendaddr; /* Server send socket */ |
48 int sock = -1; |
48 int sock = -1; |
|
49 uint16_t keys = 0x0000; |
49 |
50 |
50 extern int debug; |
51 extern int debug; |
51 |
52 |
52 |
53 |
53 void putLCDsocket(int fd, uint16_t data) |
54 void putLCDsocket(int fd, uint16_t data) |
54 { |
55 { |
|
56 socklen_t slen; |
|
57 uint16_t rdat; |
|
58 |
55 if (sock == -1) |
59 if (sock == -1) |
56 return; |
60 return; |
57 |
61 |
58 if (sendto(sock, &data, sizeof(uint16_t), 0, (struct sockaddr *)&sendaddr, sizeof(sendaddr)) != sizeof(uint16_t)) { |
62 if (sendto(sock, &data, sizeof(uint16_t), 0, (struct sockaddr *)&sendaddr, sizeof(sendaddr)) != sizeof(uint16_t)) { |
59 syslog(LOG_NOTICE, "Socket send failed, closing socket: %s", strerror(errno)); |
63 syslog(LOG_NOTICE, "Socket send failed, closing socket: %s", strerror(errno)); |
60 if (shutdown(sock, SHUT_RDWR)) { |
64 if (shutdown(sock, SHUT_RDWR)) { |
61 syslog(LOG_NOTICE, "Can't shutdown socket: %s", strerror(errno)); |
65 syslog(LOG_NOTICE, "Can't shutdown socket: %s", strerror(errno)); |
62 } |
66 } |
63 sock = -1; |
67 sock = -1; |
64 // } else { |
68 } else { |
|
69 if (recvfrom(sock, &rdat, sizeof(uint16_t), 0, (struct sockaddr *) &sendaddr, &slen) != sizeof(uint16_t)) { |
|
70 syslog(LOG_NOTICE, "Socket recvfrom failed, closing socket: %s", strerror(errno)); |
|
71 } else { |
|
72 if ((rdat & SLCD_MKEYS) == SLCD_KEYS) { |
|
73 if (((rdat & 0x00ff) != keys) && debug) |
|
74 fprintf(stdout, "received keys %04x was %04x\n", rdat & 0x00ff, keys); |
|
75 keys = rdat & 0x00ff; |
|
76 } else { |
|
77 if (debug) |
|
78 fprintf(stdout, "received %04x\n", rdat); |
|
79 } |
|
80 |
|
81 } |
65 } |
82 } |
66 } |
83 } |
67 |
84 |
|
85 |
|
86 |
|
87 void slcdDummy(int fd) |
|
88 { |
|
89 putLCDsocket(fd, SLCD_NULL); |
|
90 } |
68 |
91 |
69 |
92 |
70 //void slcdHome(int fd) |
93 //void slcdHome(int fd) |
71 //{ |
94 //{ |
72 //} |
95 //} |