Mostly minor fixes up until version 0.8.10.
[irreco.git] / irtrans / irserver / src / lowlevel.h
blob2cd611f8387c63cb5e71426c3e73772745588ada
1 /*
2 * Copyright (c) 2007, IRTrans GmbH
3 * All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of IRTrans GmbH nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY IRTrans GmbH ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL IRTrans GmbH BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 int ReadHTMLDirectory (void);
31 int SetTransceiverIDEx (int bus,byte id);
32 int GetBusInfo (STATUS_BUFFER *sb);
33 int GetBusInfoEx (STATUS_BUFFER *sb,int bus);
34 int GetBusInfoDetail (STATUS_BUFFER *sb,int bus);
35 int SetTransceiverModusEx (int bus,byte mode,word send_mask,byte addr,char *hotcode,int hotlen,byte extended_mode,byte extended_mode2,byte extended_mode3,byte extended_mode4,byte *mac);
36 int SetTransceiverModusEx2 (int bus,byte addr,char *hotcode,int hotlen);
37 int TransferFlashdataEx (int bus,word data[],int adr,int len,byte active,int iradr);
38 int ReadFlashdataEx (int bus,int adr);
39 int SendIR (int cmd_num,int address);
40 int DoSendIR (IRDATA *ir_data,IRDATA *ir_rep,int rpt_len,int rpt_pause,int bus);
41 int SendIRDataEx (IRDATA *ir_data,int address);
42 int SendLCD (IRRAW *ir_data,int address);
43 int AdvancedLCD (byte mode,byte data[],int len);
44 void LCDBrightness (int val);
45 int ResendIREx (int bus,IRDATA *ir_data);
46 byte Convert2OldCarrier (byte carrier);
47 int ResetTransceiverEx (int bus);
48 int SetPowerLED (int bus,byte mode,byte val);
49 int SetRelaisEx (int bus,byte val,byte rel);
50 int ReadAnalogInputs (int bus,byte mask,ANALOG_INPUTS *inputs);
51 int SendSerialBlock (int bus,byte data[],byte len);
53 int ReadIR (byte data[]);
54 int LearnIREx (IRDATA *ir_data,word addr,word timeout,word ir_timeout,byte carrier);
55 int LearnNextIREx (IRDATA *ir_data,word addr,word timeout,word ir_timeout,byte carrier);
56 int LearnRawIREx (IRRAW *ir_data,word addr,word timeout,word ir_timeout,byte carrier);
57 int LearnRawIRRepeatEx (IRRAW *ir_data,word addr,word timeout,word ir_timeout,byte carrier);
58 int LearnRepeatIREx (IRDATA *ir_data,word addr,word timeout,word ir_timeout,byte carrier);
59 void ResetComLines (void);
60 void CorrectIRTimings (IRDATA *ir_data);
61 void CorrectIRTimingsRAW (IRRAW *ir_data);
64 void PrintPulseData (IRDATA *ir_data);
65 void PrintCommand (IRDATA *ir_data);
66 void PrintRawData (IRRAW *ir_data);
68 int WriteTransceiverCommand (byte pnt);
69 int WriteTransceiver (IRDATA *src,byte usb_mode);
70 byte get_checksumme (IRDATA *ir);
71 void ConvertToIRTRANS3 (IRDATA *ird);
72 void ConvertToIRTRANS4 (IRDATA3 *ird);
74 int GetTransceiverVersion (char version [],unsigned int *cap,unsigned int *serno,char mac_adr[],byte usbmode);
75 int ResetTransceiver (void);
76 int InitCommunication (char device[],char version[]);
77 int InitCommunicationEx (char devicesel[]);
78 void InitConversionTables (void);
79 void ConvertLCDCharset (byte *pnt);
80 void LCDTimeCommand (byte mode);
81 void SetSpecialChars (byte dat[]);
82 void SetLCDProcCharsV (byte dat[]);
84 void FlushUSB (void);
85 void FlushCom (void);
86 void msSleep (int time);
87 int ReadIRString (byte pnt[],int len,word timeout,byte usb_mode);
88 void WriteIRString (byte pnt[],int len,byte usb_mode);
89 void GetError (int res,char st[]);
90 void log_print (char msg[],int level);
91 void Hexdump_File (IRDATA *ird);
92 void Hexdump_Medialon (IRDATA *ird);
94 void swap_irdata (IRDATA *src,IRDATA *tar);
95 void swap_word (word *pnt);
96 void swap_int (int32_t *pnt);
97 int GetByteorder (void);
98 void SwapStatusbuffer (STATUS_BUFFER *sb);
99 unsigned int GetMsTime (void);
100 int get_devices (char sel[],byte testmode);
101 int get_detail_deviceinfo (char serno[],char devnode[],byte if_type);
102 void sort_ir_devices (char selstring[]);
105 extern byte byteorder;
107 #define MINIMUM_SW_VERSION "2.18.04"
109 #ifdef LINUX
111 typedef int HANDLE;
113 #endif
115 #ifndef FTD2XX_H
117 typedef void* FT_HANDLE;
119 #endif
122 #define MAX_IR_DEVICES 256
125 #pragma pack(8)
127 #define IF_RS232 0
128 #define IF_USB 1
129 #define IF_LAN 2
130 #define IF_SERUSB 3
132 typedef struct {
133 byte if_type; // 0 = RS232 1 = USB 2 = LAN
134 byte time_len;
135 byte raw_repeat;
136 byte ext_carrier;
137 byte inst_receive_mode;
138 byte advanced_lcd;
139 byte io_seq_mode;
140 byte io_sequence;
141 char node[20];
142 FT_HANDLE usbport;
143 HANDLE comport;
144 HANDLE event;
145 struct sockaddr_in IPAddr[16];
146 char receive_buffer[4][256];
147 int receive_cnt[4];
148 int receive_buffer_cnt;
149 } IOINFO;
151 typedef struct {
152 char name[40];
153 char usb_serno[20];
154 char device_node[40];
155 char cap_string[80];
156 char version[20];
157 char lan_version[20];
158 byte mac_adr[6];
159 uint32_t fw_serno;
160 uint32_t fw_capabilities;
161 byte my_addr;
162 IOINFO io;
163 } DEVICEINFO;
166 int WriteIRStringEx (DEVICEINFO *dev,byte pnt[],int len);
167 int ReadIRStringEx (DEVICEINFO *dev,byte pnt[],int len,word timeout);
168 int WriteTransceiverEx (DEVICEINFO *dev,IRDATA *src);
169 void FlushIoEx (DEVICEINFO *dev);
170 int GetTransceiverVersionEx (DEVICEINFO *dev);
171 void FlushComEx(HANDLE fp);
172 void CancelLearnEx (DEVICEINFO *dev);
173 int ReadInstantReceive (DEVICEINFO *dev,byte pnt[],int len);
174 int GetAvailableDataEx (DEVICEINFO *dev);
175 int IRTransLanSend (DEVICEINFO *dev,IRDATA *ird);
178 extern DEVICEINFO IRDevices[MAX_IR_DEVICES];
179 extern int device_cnt;
181 extern char hexfile[256];
182 extern FILE *hexfp;
183 extern byte hexflag;
186 #define TABLE_CNT 2
188 extern byte DispConvTable[TABLE_CNT][256];