int g15_send(int sock, char *buf, unsigned int len);
.br
int g15_recv(int sock, char *buf, unsigned int len);
.br
int g15_send_cmd (int sock, unsigned char command, unsigned char value);
.br
.SH "G15Daemon Server / Client communication"
G15Daemon uses INET sockets to talk to its clients, listening on localhost port 15550 for connection requests. Once connected, the server sends the text string "G15 daemon HELLO" to confirm to the client that it is a valid g15daemon process, creates a new screen, and waits for LCD buffers or commands to be sent from the client. Clients are able to create multiple screens simply by opening more socket connections to the server process. If the socket is closed or the client exits, all LCD buffers and the screen associated with that socket are automatically destroyed.
Clients wishing to display on the LCD must send entire screens in the format of their choice. Currently partial screen updates (icons etc) are not supported.
G15Daemon commands are sent to the daemon via the OOB (out\-of\-band) messagetype, replies are sent inband back to the client.
.SH "int new_g15_screen(int screentype)"
Opens a new connection and returns a network socket for use. Creates a screen with one of the following pixel formats defined in g15daemon_client.h:
G15_PIXELBUF: this buffer must be exactly 6880 bytes, and uses 1 byte per pixel.
G15_TEXTBUF: currently ignored by the daemon.
G15_WBMPBUF: this is a packed pixel buffer in WBMP format with 8 pixels per byte. Useful for perl programmers using the GD:: and G15Daemon.pm (see lang_bindings directory) perl modules.
G15_G15RBUF: another packed pixel buffer type, also with 8 pixels/byte, and is the native libg15render format.
Example of use:
int screen_fd = new_g15_screen( G15_WBMPBUF );
.SH "int g15_close_screen (int screen_fd)"
Simply closes a socket previously opened with new_g15_screen(). The daemon will automatically clean up any buffers and remove the LCD screen from the display list.
Returns 0 if successful, or errno if there was an error.
.SH "int g15_send (int sock, char *buf, unsigned int len)"
A simple wrapper around send() to ensure that all 'len' bytes of data is sent to the daemon. It simply uses poll() to block until the entire message is sent.
Returns 0 on success, \-1 if the send failed due to timeout or socket error.
.SH "int g15_recv (int sock, char *buf, unsigned int len)"
A simple wrapper around recv() to ensure that all 'len' bytes of data are received from the daemon. It simply uses poll() to block until the entire message is received.
Returns 0 on success, \-1 if the recv failed due to timeout or socket error.
Sends a command to the daemon (possible commands are listed below). Returns 0 or the return value of the command on success, \-1 on failure.
See examples for usage.
.SH "G15Daemon Command Types"
.P
Commands and requests to the daemon are sent via OOB data packets. Changes to the backlight and mkey state will only affect the calling client. The following commands are supported as defined in g15daemon_client.h:
.IP "G15DAEMON_KEY_HANDLER"
Requests that all M and G key presses are sent to this client. All keys are packed into an unsigned int, and sent to the client inband when a key is pressed.
.IP "G15DAEMON_MKEYLEDS"
Sets the M key LED state. In order to change LED state, each LED that is to be turned on is OR'd with the command byte. See libg15.h for values. For examples see the end of this document.
.IP "G15DAEMON_BACKLIGHT"
Sets the LCD Backlight brightness. Brightness level (0|1|2) is OR'd with the command byte. For examples see the end of this document.
.IP "G15DAEMON_CONTRAST"
Sets the LCD contrast. Contrast level (0|1|2) is OR'd with the command byte. For examples see the end of this document.
.IP "G15DAEMON_GET_KEYSTATE"
Requests a packet containing the current keystate. The daemon will return an unsigned int containing any keys pressed. See libg15.h for details on key values, and lcdclient_test.c in the source distribution for an example.
.IP "G15DAEMON_SWITCH_PRIORITIES"
Toggles the client's LCD screen to/from the front. Clients can check their foreground/background state with the following:
.IP "G15DAEMON_IS_FOREGROUND"
On reciept of this command, G15Daemon will send a 1 byte packet back with the value 1 if the client is foreground, or 0 if not.
.IP "G15DAEMON_IS_USER_SELECTED"
On reciept of this command, G15daemon will return a byte indicating if the user selected the client be foreground or background.
.SH "EXAMPLES"
Below is a completely nonsensical client which (poorly) demonstrates the usage of most of the commands.