1 | #define LCDPORT 13666 |
---|
2 | |
---|
3 | /********************************************************************** |
---|
4 | LCDproc socket interface grammar: |
---|
5 | |
---|
6 | RawText Print whatever you send, at whatever the current position is. |
---|
7 | |
---|
8 | or... |
---|
9 | |
---|
10 | 0xFE Command prefix, followed by... |
---|
11 | |
---|
12 | 0x00 EOT. End of transmission, where applicicable. |
---|
13 | 0x01 Ping. Will respond with a "pong". |
---|
14 | 'k',x Send "keypad" input, character x (A-Z) |
---|
15 | |
---|
16 | ?,x,...,EOT Send new mode sequence (x,...)... |
---|
17 | ?,x Switch to new mode x immediately |
---|
18 | ?,xxxx Pause in current mode for x frames/seconds (0=infinite) |
---|
19 | ? Play -- continue mode cycle. |
---|
20 | ?,x,y,...,EOT |
---|
21 | Send raw text to be displayed. x is style (raw, wrapped), |
---|
22 | and y is num frames between lines displayed. |
---|
23 | |
---|
24 | ?,... Send MtxOrb-like control commands (bargraphs, etc) |
---|
25 | |
---|
26 | ... more to come later ... |
---|
27 | **********************************************************************/ |
---|
28 | |
---|
29 | /***************************************************************** |
---|
30 | LCDproc command line interface: (while running) |
---|
31 | |
---|
32 | -command |
---|
33 | Tells LCDproc to interpret stdin as raw commands to send through |
---|
34 | the socket. Input must be formatted as above, in socket interface. |
---|
35 | -function f |
---|
36 | Runs LCDproc external function f, where f is one of the predefined |
---|
37 | functions which can be assigned to keypad keys. (like NEXTMODE, etc) |
---|
38 | -key x |
---|
39 | Simulates keypad press of key 'x', where 'x' is (A-Z). |
---|
40 | -print [time] |
---|
41 | Prints stdin on LCD one line at a time, with no line-wrapping (raw), |
---|
42 | with [time] frames between updates (lines). |
---|
43 | -wrap [time] |
---|
44 | Prints stdin as with "-print", but with line wrapping when possible. |
---|
45 | -contrast xxx |
---|
46 | Sets contrast to xxx (decimal) |
---|
47 | -backlight [on/off] |
---|
48 | Turns backlight [on/off/auto], or toggles it. |
---|
49 | If [off], stays off. |
---|
50 | If [on], stays on. |
---|
51 | If [auto], LCDproc controls backlight based on load, etc... |
---|
52 | -exit |
---|
53 | -quit |
---|
54 | Duh... :) |
---|
55 | |
---|
56 | ******************************************************************/ |
---|
57 | |
---|
58 | /***************************************************************** |
---|
59 | LCDproc stuff supported in config file (loose approximation): |
---|
60 | |
---|
61 | Grammar is tcl-style. I.e., "command arg1 arg2 ...". |
---|
62 | Spaces are used as argument separators, *until* it thinks it has the final |
---|
63 | argument. So, "function thing shell myprogram arg1 arg2 arg3" would be |
---|
64 | split into "function", "thing", "shell", and "myprogram arg1 arg2 arg3". |
---|
65 | |
---|
66 | User-definable functions (use built-in's to create new ones?): |
---|
67 | Function mp3NextSong Shell /usr/local/bin/mp3player -next |
---|
68 | Function MySequence Sequence cpu mem xload |
---|
69 | Function OtherSequence Sequence time cd xload |
---|
70 | |
---|
71 | Keypad keys can be bound to any _function_: |
---|
72 | Key A mp3NextSong |
---|
73 | Key B HaltSystem |
---|
74 | Key C Menu |
---|
75 | Key D Next/+ |
---|
76 | Key E OtherSequence |
---|
77 | |
---|
78 | |
---|
79 | ******************************************************************/ |
---|
80 | |
---|
81 | typedef struct sockaddr_in sockaddr_in; |
---|
82 | |
---|
83 | int init_sockaddr (sockaddr_in *name, |
---|
84 | const char *hostname, |
---|
85 | unsigned short int port); |
---|
86 | |
---|
87 | // Creates a socket in internet space |
---|
88 | int CreateInetSocket(unsigned short int port); |
---|
89 | |
---|
90 | // Checks the LCDproc port for a response... |
---|
91 | int PingLCDport(); |
---|
92 | |
---|
93 | int StartSocketServer(); |
---|
94 | |
---|
95 | int PollSockets(); |
---|
96 | |
---|
97 | int read_from_client (int filedes); |
---|
98 | |
---|
99 | int CloseAllConnections(); |
---|