/**************************************************************************************/ /* Header for Sendrec.c */ /* Copyright(C)1999 Peter Armstrong */ /* Release 2.0 */ /**************************************************************************************/ /* function return and command reply values */ #define OK 1 #define NG 0 #define BAD -1 /* also indicates timeout for some functions */ #define TIMEOUT -2 /* header defines */ #define HDR_SIZE 8 /* header byte length, °HEADR */ #define H_CHKSUM 7 /* checksum index position */ #define H_SIZE 6 /* size index position */ #define INTER_SIZE 8 /* size of integer array,°IT<4byte integer> */ #define INTER_NUM 3 /* integer start in array */ #define REPLY_SIZE 1 /* OK/NG/BAD */ #define MAX_RETRIES 5 /* max send/rec retries */ /* command prefixes */ #define PSX_CMD 0xFD #define PSX2_CMD 0xFC #define PC_CMD 0xFB #define FS_CMD 0xF8 /* indexes for data within commands */ #define MSG_ID 0 /* message identifier */ #define CMD_ID 1 /* individual command id */ #define CMD_CHKSUM 7 /* command's checksum */ #define CMD_SIZE 8 /* command size */ /* ²CNTx00 */ #define CNT_TYPE 4 /* connection type */ /* ²STxx00 */ #define ST_SIZE 3 /* start data size */ #define ST_DIFF 4 /* start frame difference */ /* ²ACKx00 */ #define ACK_VAL 4 /* command acknowledge value */ /* psx command identifiers */ #define PCMD_CNT 'C' /* connect */ #define PCMD_XCNT 'X' /* cancel previous connect command */ #define PCMD_START 'S' /* packet transfer start */ #define PCMD_ACK 'A' /* command received acknowledgement */ #define PCMD_DISC 'D' /* break connection */ #define PCMD_EXIT 'E' /* remote psx exit notification */ #define PCMD_BLOCK 'B' /* read/write/canx data block transfer */ /* commands/messages read/written within callback function */ struct cmds { int exit; /* remote psx has quit */ int command; /* stored command to be sent */ int loc_reply; /* stored reply to be sent */ int rem_reply; /* command reply received */ int reply_await; /* local waiting for a reply from remote */ int connect; /* connect command received */ int cnt_type; /* remote connect command value */ int start; /* start command received */ int st_size; /* remote start command packet data size value */ int st_diff; /* remote start command frame difference value */ int acknowledge; /* acknowledge command stored */ int ack_val; /* acknowledge value */ int block; /* read/write block command received */ int blk_id; /* block identifier */ u_char *cmd; /* command to send */ char loc_rpy; /* local reply value */ char rem_rpy; /* remote reply value */ }; /* prototypes */ int Read_Text(char *text_str,char *hdr_p); int Read_Header(char *hdr_p); int Read_Text_Str(char *text_p, int size); int Send_Text(char *text_p); int Send_Header(int size); int Send_Text_Str(char *text_p, int size); int Read_Integer(int *int_p); int Send_Integer(int num); int Read_WrReply(u_int timer); int Read_Reply(u_int timer); void Send_Reply(char rpy_val); int Port_Write(char *data_p,int size); int Port_Read(char *read_p,int to_read, u_int timer); void vs_PsxCmds(void); void vs_Read_PsxReply(char rpy); int vs_Sio_CmdRead(char *buffer, int num); void vs_Read_PsxCmd(u_char *rem_cmd); int Send_PsxCmd(u_char *loc_cmd); int Cmd_Reply(int rpy_val);