From 62bc1af6c6a1201db551e1ec523e757415464fd5 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 25 Oct 2020 13:26:29 +0000 Subject: tidy up, make less awful --- sia.h | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 sia.h (limited to 'sia.h') diff --git a/sia.h b/sia.h new file mode 100644 index 0000000..71a8c9d --- /dev/null +++ b/sia.h @@ -0,0 +1,66 @@ +#ifndef _sia_h_ +#define _sia_h_ + +#define SIA_TIMEOUT 3 // standard says 2.5s + +#define SIA_FN_ACCOUNT_ID 0x23 +#define SIA_FN_ORIGIN_ID 0x26 +#define SIA_FN_END_OF_DATA 0x30 +#define SIA_FN_WAIT 0x31 +#define SIA_FN_ABORT 0x32 +#define SIA_FN_RES_3 0x33 +#define SIA_FN_RES_4 0x34 +#define SIA_FN_RES_5 0x35 +#define SIA_FN_ACK_AND_STANDBY 0x36 +#define SIA_FN_ACK_AND_DISCONNECT 0x37 +#define SIA_FN_ACKNOLEDGE 0x38 +#define SIA_FN_ALT_ACKNOLEDGE 0x08 //JMM I can't imagine how someone made that mistake :) +#define SIA_FN_REJECT 0x39 +#define SIA_FN_ALT_REJECT 0x09 +#define SIA_FN_REMOTE_LOGIN 0x3f +#define SIA_FN_CONFIGURATION 0x40 +#define SIA_FN_ASCII 0x41 +#define SIA_FN_CONTROL 0x43 +#define SIA_FN_ENVIRONMENTAL 0x45 +#define SIA_FN_VIDEO 0x49 +#define SIA_FN_LISTEN_IN 0x4c +#define SIA_FN_NEW_EVENT 0x4e +#define SIA_FN_OLD_EVENT 0x4f +#define SIA_FN_PROGRAM 0x50 +#define SIA_FN_VCHN_REQUEST 0x56 +#define SIA_FN_EXTENDED 0x58 +#define SIA_FN_VCHN_FRAME 0x76 + + +#define SIA_MAX_DATA_LENGTH 0x3f +#define SIA_MAX_BLOCK_LENGTH (2 + SIA_MAX_DATA_LENGTH + 1) + +typedef union { + unsigned char block[SIA_MAX_BLOCK_LENGTH]; + struct { + unsigned char length : 6; + unsigned char request_ack: 1; + unsigned char reverse_channel: 1; + unsigned char function; + unsigned char data[]; + }; +} SIA_Block; + + +/* sia.c */ +extern int sia_fn_valid (SIA_Block *s); +extern int sia_fn_permits_ack (unsigned char fn); +extern unsigned int sia_data_length (SIA_Block *s); +extern unsigned int sia_length (SIA_Block *s); +extern int sia_parity_valid (SIA_Block *s); +extern void sia_set_parity (SIA_Block *s); +extern ssize_t sia_write (int fd, SIA_Block *s); +extern ssize_t sia_acknoledge (int fd); +extern int sia_ack_if_needed (int fd, SIA_Block *s); +extern int sia_parse (unsigned char *buf, unsigned len, SIA_Block *b); +extern int sia_rx_with_timeout (int fd, SIA_Block *b, int timeout); +extern int sia_rx_with_timeout_ignore_log (int fd, SIA_Block *b, int timeout); +extern int sia_login (int fd, SIA_Block *b); + + +#endif /* _sia_h_ */ -- cgit v1.2.3