1 | #include <usb.h>
|
2 | #include <stdio.h>
|
3 | #include <getopt.h> // needed for getopt
|
4 |
|
5 | extern usb_dev_handle *g_Dev;
|
6 | extern int g_iFlags;
|
7 | extern void abort(const char *fmt, ...);
|
8 |
|
9 | #define WARMINGUP 0x01
|
10 | #define NO_BEAM 0x02
|
11 | #define INTERRUPTED_BEAM 0x04
|
12 | #define KEYBOARD 0x08
|
13 |
|
14 | typedef struct transdata { // data
|
15 | int bAlign; // 0: distance, 1: intensity
|
16 | int n;
|
17 | long long lldata[100];
|
18 | } TransData;
|
19 |
|
20 | //only this file////////////////////////////////////////////////
|
21 |
|
22 | #define NEXT_RING_INDEX(x, y) (((x+1)<y)?(x+1):(x+1-y))
|
23 | #define MAX_STREAM0x82 25
|
24 | #define BUFFLEN0x82 0x1000
|
25 | struct { // data for asynchronous streams
|
26 | void* async;
|
27 | char buff[BUFFLEN0x82];
|
28 | } g_sPayload0x82[MAX_STREAM0x82];
|
29 | int g_iPayload0x82_index; // active stream
|
30 |
|
31 | unsigned char g_commandcount=1;
|
32 |
|
33 |
|
34 | // Normal pipe 82 usb packets have a length of 4096 bytes.
|
35 | // Only the very last packet has a length of 12 bytes, which is the pure packet-header.
|
36 | //
|
37 | // 0 12 512 ... 4095
|
38 | // +----------+------------------------+---+---+---+ ... +---+
|
39 | // | 12 bytes | 500 bytes | 3584 bytes| | |
|
40 | // | packet- | allways | payload | | |
|
41 | // | header | 0x00 | (56*64 bytes) | |
|
42 | // +----------+------------------------+---+---+---+ ... +---+
|
43 | //
|
44 | //
|
45 | int xl80_eval(int len, int iStep, TransData *transdata)
|
46 | {
|
47 | static unsigned char ring_counter=0x01;
|
48 | static char xe_timer=0;
|
49 | int i, j;
|
50 |
|
51 | // initialisize very first xe_timer
|
52 | if (!xe_timer)
|
53 | xe_timer=(g_sPayload0x82[g_iPayload0x82_index].buff[518]>>4)&0x0f;
|
54 |
|
55 | // normal length?
|
56 | if (len != 4096)
|
57 | return 0;
|
58 |
|
59 | // Structure of the packet-header (12 bytes):
|
60 | // +------------------------------------- allways 0x80
|
61 | // | +---------------------------------- ring_counter 0x01 to 0xff (never 0x00)
|
62 | // | | +------------------------------- opposide counter (sum of both counters is 0xff)
|
63 | // | | | +---------------------------- allways 0
|
64 | // | | | | +------------------------- (short) normal:0x0E00=3584, very last packet:0, ?valid payload length
|
65 | // | | | | | +------------------- (short) allways 0
|
66 | // | | | | | | +------------- (short) normal:0, very last packet:1, ?end-mark
|
67 | // | | | | | | | +------- (short) normal:0x01f4=500, very last packet:0, ?frequency/100
|
68 | // | | | | | | | |
|
69 | // vv vv vv vv vvvvv vvvvv vvvvv vvvvv|
|
70 | // sample: 80 01 fe 00 00 0e 00 00 00 00 f4 01|
|
71 | // offset: 1 1 |
|
72 | // 0 1 2 3 4 5 6 7 8 9 0 1 |
|
73 | //
|
74 | // check packet-header
|
75 | if (*(unsigned char*)&g_sPayload0x82[g_iPayload0x82_index].buff[0] != 0x80) abort("\nERROR: not 0x80\n");
|
76 | if (*(unsigned char*)&g_sPayload0x82[g_iPayload0x82_index].buff[1] != ring_counter)
|
77 | abort("\nERROR: unsynced data\n");
|
78 | if (*(unsigned char*)&g_sPayload0x82[g_iPayload0x82_index].buff[1] +
|
79 | *(unsigned char*)&g_sPayload0x82[g_iPayload0x82_index].buff[2] != 0xff)
|
80 | abort("\nERROR: unsynced sum\n");
|
81 | if (!++ring_counter) ring_counter++;
|
82 | if (*(unsigned char*)&g_sPayload0x82[g_iPayload0x82_index].buff[3] != 0) abort("\nERROR: not a 0\n");
|
83 | if (*(short*)&g_sPayload0x82[g_iPayload0x82_index].buff[4] != 3584) abort("\nERROR: not 3584\n");
|
84 | if (*(short*)&g_sPayload0x82[g_iPayload0x82_index].buff[6] != 0) abort("\nERROR: not b 0\n");
|
85 | if (*(short*)&g_sPayload0x82[g_iPayload0x82_index].buff[8] != 0) abort("\nERROR: not c 0\n");
|
86 | if (*(short*)&g_sPayload0x82[g_iPayload0x82_index].buff[10] != 500) abort("\nERROR: not 500\n");
|
87 |
|
88 |
|
89 | // The payload are 56 * 64 bytes (= 3584 = 4096 - 512).
|
90 | // Structure of single payload packet (64 bytes):
|
91 | // +----------------------------------------------------------------------------------------- distance: here 3844
|
92 | // | +---- -5=> ----+-------------------------------------------------------- xe x:counter-5(+16), e:0xe
|
93 | // | | +-- +4or5=> ---+----------------------------------------------------- nx x:counter+4or5(-8), n:0x0
|
94 | // | | | +----------------------------------------------------------------- offset to distance
|
95 | // | | | | | | +---------------------- normal measurement 0x1c21
|
96 | // | | | | | | | +---------------- mostly 0, rarely 0x0400/0x0500
|
97 | // | | | | | | | | +---------- intensity
|
98 | // | | | | | | | | | +------- up-counter 0x00-0xff
|
99 | // | | | | | | | | | | +---- down-counter 0xff-0x00 (sum is 0xff)
|
100 | // | | | | | | | | | | | +- toggels 0xaa and 0x55
|
101 | // vvvvvvvvvvv |vv vv vvvvv |vv vv |...| |vvvvv vvvvv vv vv vv vv
|
102 | // sample: 04 0f 00 00 00 00|0e 03 02 00 00|be 07 01 00 00|...|3e 05 00 00 00|21 1c 00 00 9c af 50 aa
|
103 | // offset: | 1 |1 1 1 1 1 |...|5 5 5 5 5 |5 5 5 5 6 6 6 6
|
104 | // 0 1 2 3 4 5 |6 7 8 9 0 |1 2 3 4 5 |...|1 2 3 4 5 |6 7 8 9 0 1 2 3
|
105 | // distance |1. offset |2. offset |...|10. offset |flags etc
|
106 | // = identical to distance of next payload packet
|
107 | // -----------------------#---------------------------------------------------##-##------------------ Errors
|
108 | // 80 : No beam
|
109 | // 80 : Set zero
|
110 | // 80: Warming up
|
111 | // 02: Non continuous beam
|
112 | // 01: Intensity under 50 percent (=orange)
|
113 | // 40: ?? flickers
|
114 | // 08: ?? flickers
|
115 | // 04: ?? flickers
|
116 | // 10: ?? continuous on
|
117 | // 01 : ?? continuous on
|
118 | // 20 : ?? continuous on
|
119 | // 00 21 1c: "often seen"
|
120 | //
|
121 | // ---------------------------------------------------------------------------------------##-------- Intensity
|
122 | // 0x90: 5 green
|
123 | // 0x80: 4 greeen
|
124 | // 0x70: 3 green
|
125 | // 0x60: 2 green
|
126 | // 0x50: 1 green
|
127 | // 0x40: orange
|
128 | // 0x30: orange
|
129 | // 0x20: orange
|
130 | // 0x10: red
|
131 | // 0x00: red
|
132 |
|
133 | #define STANDARD_MEASURE_FREQUENCY 5000
|
134 |
|
135 | long long distance;
|
136 | int no;
|
137 | for (i=512, no=0; i<len; i+=64) {
|
138 | if (++transdata->n >= iStep) { // output this data packet
|
139 | transdata->n=0;
|
140 |
|
141 | if (transdata->bAlign)
|
142 | distance=(long long)(*(unsigned char*)&g_sPayload0x82[g_iPayload0x82_index].buff[i+60])*2/3; // intensity
|
143 | else
|
144 | distance=(long long)(*(long long*)&g_sPayload0x82[g_iPayload0x82_index].buff[i+0]<<17)>>17; // distance
|
145 |
|
146 | transdata->lldata[no++]=distance;
|
147 | if (no<0)
|
148 | abort("\nERROR: underflow in transdata\n");
|
149 | if (no>= sizeof(transdata->lldata)/8)
|
150 | abort("\nERROR: overflow in transdata\n");
|
151 | }
|
152 | if (*(unsigned short*)&g_sPayload0x82[g_iPayload0x82_index].buff[i+4] & 0x8000)
|
153 | g_iFlags=g_iFlags | NO_BEAM;
|
154 | if (*(unsigned short*)&g_sPayload0x82[g_iPayload0x82_index].buff[i+56] & 0x8000)
|
155 | g_iFlags=g_iFlags | WARMINGUP;
|
156 | if (*(unsigned short*)&g_sPayload0x82[g_iPayload0x82_index].buff[i+56] & 0x0200)
|
157 | g_iFlags=g_iFlags | INTERRUPTED_BEAM;
|
158 |
|
159 | if ((*(unsigned char*)&g_sPayload0x82[g_iPayload0x82_index].buff[i+61] +
|
160 | *(unsigned char*)&g_sPayload0x82[g_iPayload0x82_index].buff[i+62])&0xff != 0xff)
|
161 | abort("\nERROR: [61,62] unsynced sum %02X %02X\n",
|
162 | *(unsigned char*)&g_sPayload0x82[g_iPayload0x82_index].buff[i+61],
|
163 | *(unsigned char*)&g_sPayload0x82[g_iPayload0x82_index].buff[i+62]);
|
164 |
|
165 | #if 0 // 50Hz evaluation
|
166 | for (j=0; j<10; j++) {
|
167 | if (g_sPayload0x82[g_iPayload0x82_index].buff[i+6+j*5] != xe_timer<<4 & 0x0e)
|
168 | abort("\nERROR: wrong xe_timer\n");
|
169 | xe_timer-=5; if (xe_timer<0) xe_timer+=16;
|
170 | distance+=*(short*)&g_sPayload0x82[g_iPayload0x82_index].buff[i+8+j*5];
|
171 | printf("(%d)", distance);
|
172 | // printf(" %.8f\n", distance/WAVES_PER_MM/64); // timing problems
|
173 | }
|
174 | #endif
|
175 |
|
176 | }
|
177 | return no;
|
178 | }
|
179 |
|
180 |
|
181 |
|
182 |
|
183 |
|
184 | // usb_init(); // initialize the library
|
185 | // usb_find_busses(); // find all buses
|
186 | // usb_find_devices(); // find all connected devices [GET_DESCRIPTOR_FROM_DEVICE:80 06 0100 0000 0012
|
187 | // // GET_DESCRIPTOR_FROM_DEVICE:80 06 0200 0000 0008
|
188 | // // GET_DESCRIPTOR_FROM_DEVICE:80 06 0200 0000 00xx]
|
189 | // g_Dev = open_dev();
|
190 | // usb_set_configuration(g_Dev, 1); // select configuration [GET_DESCRIPTOR_FROM_DEVICE:80 06 0100 0000 0012
|
191 | // // GET_DESCRIPTOR_FROM_DEVICE:80 06 0200 0000 0009
|
192 | // // GET_DESCRIPTOR_FROM_DEVICE:80 06 0200 0000 00xx
|
193 | // // SELECT_CONFIGURATION:config]
|
194 | // usb_claim_interface(g_Dev, 0);
|
195 |
|
196 | void xl80_start_seq1()
|
197 | {
|
198 | int i, ret;
|
199 | char data[4096+4];
|
200 | // +--------------------------------------------------- usb_dev_handle
|
201 | // | +--------------------------------------------# int requesttype (SetupPacket:byte 0)
|
202 | // | | +--------------------------------------# int request (SetupPacket:byte 1)
|
203 | // | | | +--------------------------------## int value (SetupPacket:bytes 3,2)
|
204 | // | | | | +------------------------## int index (SetupPacket:bytes 5,4)
|
205 | // | | | | | +---------------- char *bytes returned values
|
206 | // | | | | | | +----------## int size (SetupPacket:bytes 7,6)
|
207 | // | | | | | | | +-- int timeout
|
208 | // v v v v v v v v
|
209 |
|
210 | if (usb_control_msg(g_Dev, 0x80, 0x08, 0x0000, 0x0000, data, 0x0001, 1000) < 0) // [GET_CONFIGURATION:80 08 0000 0000 0001]
|
211 | abort("\nERROR: usb_control_msg %s: ", usb_strerror());
|
212 | if (data[0] != 1)
|
213 | abort("\nERROR: wrong configuration\n");
|
214 |
|
215 | char recv0[]={0x01,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
|
216 | if (usb_control_msg(g_Dev, 0xa1, 0x07, 0x0000, 0x0000, data, 0x0018, 1000) < 0) // [CLASS_INTERFACE:a1 07 0000 0000 0018]
|
217 | abort("\nERROR: usb_control_msg%s: ", usb_strerror());
|
218 | for(i=0; i<0x18; i++)
|
219 | if (data[i]!=recv0[i])
|
220 | printf("diff %3d: %02x %02X\n", i, (unsigned char)data[i], (unsigned char)recv0[i]);
|
221 |
|
222 | if (usb_clear_halt(g_Dev, 0x01) < 0) // [RESET_PIPE]
|
223 | abort("\nERROR: reset%s: ", usb_strerror());
|
224 | if (usb_clear_halt(g_Dev, 0x81) < 0) // [RESET_PIPE]
|
225 | abort("\nERROR: reset%s: ", usb_strerror());
|
226 | if (usb_clear_halt(g_Dev, 0x82) < 0) // [RESET_PIPE]
|
227 | abort("\nERROR: reset%s: ", usb_strerror());
|
228 |
|
229 | char send1[]={0x01,g_commandcount,0xff-g_commandcount,0x00,0x04,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x02,0x00,0x00,0x00};
|
230 | if (usb_bulk_write(g_Dev, 0x01, send1, sizeof(send1), 1000)<0) // [BULK_OR_INTERRUPT_TRANSFERdown:01 01 fe 00 04 00 00 00 01 00 00 00 02 00 00 00]
|
231 | abort("\nERROR: a usb_bulk_write%s: ", usb_strerror());
|
232 | if (usb_control_msg(g_Dev, 0x82, 0x00, 0x0000, 0x0001, data, 0x0002, 1000) < 0) // [GET_STATUS_FROM_ENDPOINT: 82 00 0000 0001 0002]
|
233 | abort("\nERROR: usb_control_msg%s: ", usb_strerror());
|
234 | if (*(short*)&data[0] != 0)
|
235 | abort("\nERROR: status is %04x\n", *(short*)&data[0]);
|
236 |
|
237 | g_commandcount++;
|
238 | char send2[]={0x02,g_commandcount,0xff-g_commandcount,0x00,0x0d,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
|
239 | if (usb_bulk_write(g_Dev, 0x01, send2, sizeof(send2), 1000) < 0) // [BULK_OR_INTERRUPT_TRANSFERdown:02 02 fd 00 0d 00 00 00 00 00 00 00]
|
240 | abort("\nERROR: b usb_bulk_write%s: ", usb_strerror());
|
241 | if(usb_control_msg(g_Dev, 0x82, 0x00, 0x0000, 0x0001, data, 0x0002, 1000) < 0) // [GET_STATUS_FROM_ENDPOINT: 82 00 0000 0001 0002]
|
242 | abort("\nERROR: usb_control_msg%s: ", usb_strerror());
|
243 | char recv2[]={0x02,g_commandcount,0xff-g_commandcount,0x00,0x0d,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x77,0x84,0x5c,0x74,0x75,0x41,0xe4,0x3f,0x5c};
|
244 | if ((ret=usb_bulk_read(g_Dev, 0x81, data, 4096, 1000)) < 0) // [BULK_OR_INTERRUPT_TRANSFERback:02 02 fd 00 0d 00 00 00 01 00 00 00 02 00 00 00 77 84 5c 74 75 41 e4 3f 5c]
|
245 | abort("\nERROR: usb_bulk_read%s: ", usb_strerror());
|
246 | for(i=0; i<ret; i++)
|
247 | if (data[i]!=recv2[i])
|
248 | printf("diff %3d: %02x %02X\n", i, (unsigned char)data[i], (unsigned char)recv2[i]);
|
249 |
|
250 | g_iPayload0x82_index=-1;
|
251 | }
|
252 |
|
253 | // either (..._seq234) or (..._seq2 to ..._seq4)
|
254 | void xl80_zero_seq234()
|
255 | {
|
256 | char data[4096+4];
|
257 | // set zero command
|
258 | g_commandcount++;
|
259 | char send3[]={0x01,g_commandcount,0xff-g_commandcount,0x00,0x04,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x10,0x00,0x00,0x80};
|
260 | if (usb_bulk_write(g_Dev, 0x01, send3, sizeof(send3), 1000) < 0) // [BULK_OR_INTERRUPT_TRANSFERdown:01 03 fc 00 04 00 00 00 01 00 00 00 10 00 00 80]
|
261 | abort("\nERROR: c usb_bulk_write%s: ", usb_strerror());
|
262 | if(usb_control_msg(g_Dev, 0x82, 0x00, 0x0000, 0x0001, data, 0x0002, 1000) < 0) // [GET_STATUS_FROM_ENDPOINT: 82 00 0000 0001 0002]
|
263 | abort("\nERROR: usb_control_msg%s: ", usb_strerror());
|
264 | }
|
265 |
|
266 | void xl80_pre_loop_seq2()
|
267 | {
|
268 | int i, ret;
|
269 | char data[4096+4];
|
270 |
|
271 | // optional command??
|
272 | g_commandcount++;
|
273 | char send4[]={0x01,g_commandcount,0xff-g_commandcount,0x00,0x05,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x08,0x00,0x00,0x80,0x04,0x00,0x00,0x00};
|
274 | if (usb_bulk_write(g_Dev, 0x01, send4, sizeof(send4), 1000) < 0) // [BULK_OR_INTERRUPT_TRANSFERdown:01 04 fb 00 05 00 00 00 01 00 00 00 08 00 00 80 04 00 00 00]
|
275 | abort("\nERROR: d usb_bulk_write%s: ", usb_strerror());
|
276 | if(usb_control_msg(g_Dev, 0x82, 0x00, 0x0000, 0x0001, data, 0x0002, 1000) < 0) // [GET_STATUS_FROM_ENDPOINT: 82 00 0000 0001 0002]
|
277 | abort("\nERROR: usb_control_msg%s: ", usb_strerror());
|
278 |
|
279 | // optional command??
|
280 | g_commandcount++;
|
281 | char send5[]={0x01,g_commandcount,0xff-g_commandcount,0x00,0x05,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x09,0x00,0x00,0x80,0x01,0x00,0x00,0x00};
|
282 | if (usb_bulk_write(g_Dev, 0x01, send5, sizeof(send5), 1000) < 0) // [BULK_OR_INTERRUPT_TRANSFERdown:01 05 fa 00 05 00 00 00 01 00 00 00 09 00 00 80 01 00 00 00]
|
283 | abort("\nERROR: switch off and on the laser!!!\nusb_bulk_write%s: ", usb_strerror());
|
284 | if(usb_control_msg(g_Dev, 0x82, 0x00, 0x0000, 0x0001, data, 0x0002, 1000) < 0) // [GET_STATUS_FROM_ENDPOINT: 82 00 0000 0001 0002]
|
285 | abort("\nERROR: usb_control_msg%s: ", usb_strerror());
|
286 |
|
287 | g_commandcount++;
|
288 | char send6[]={0x01,g_commandcount,0xff-g_commandcount,0x00,0x04,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x03,0x00,0x00,0x00};
|
289 | if (usb_bulk_write(g_Dev, 0x01, send6, sizeof(send6), 1000) < 0) // [BULK_OR_INTERRUPT_TRANSFERdown:01 06 f9 00 04 00 00 00 01 00 00 00 03 00 00 00]
|
290 | abort("\nERROR: f usb_bulk_write%s: ", usb_strerror());
|
291 | if(usb_control_msg(g_Dev, 0x82, 0x00, 0x0000, 0x0001, data, 0x0002, 1000) < 0) // [GET_STATUS_FROM_ENDPOINT: 82 00 0000 0001 0002]
|
292 | abort("\nERROR: usb_control_msg%s: ", usb_strerror());
|
293 |
|
294 | g_commandcount++;
|
295 | char send7[]={0x02,g_commandcount,0xff-g_commandcount,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
|
296 | if (usb_bulk_write(g_Dev, 0x01, send7, sizeof(send7), 1000) < 0) // [BULK_OR_INTERRUPT_TRANSFERdown:02 07 f8 00 08 00 00 00 00 00 00 00]
|
297 | abort("\nERROR: g usb_bulk_write%s: ", usb_strerror());
|
298 | if(usb_control_msg(g_Dev, 0x82, 0x00, 0x0000, 0x0001, data, 0x0002, 1000) < 0) // [GET_STATUS_FROM_ENDPOINT: 82 00 0000 0001 0002]
|
299 | abort("\nERROR: usb_control_msg%s: ", usb_strerror());
|
300 | char recv7[]={0x02,g_commandcount,0xff-g_commandcount,0x00,0x08,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x02,0x30,0x01,0x06};
|
301 | if ((ret=usb_bulk_read(g_Dev, 0x81, data, 4096, 1000)) < 0) // [BULK_OR_INTERRUPT_TRANSFERback:02 07 f8 00 08 00 00 00 01 00 00 00 03 00 00 00 02 30 01 06]
|
302 | abort("\nERROR: usb_bulk_read%s: ", usb_strerror());
|
303 | for(i=0; i<ret; i++)
|
304 | if (data[i]!=recv7[i])
|
305 | printf("diff %3d: %02x %02X\n", i, (unsigned char)data[i], (unsigned char)recv7[i]);
|
306 |
|
307 | if(usb_control_msg(g_Dev, 0x42, 0x80, 0x0000, 0x0082, data, 0x0000, 1000) < 0) // [VENDOR_ENDPOINT:42 80 0000 0082 0000]
|
308 | abort("\nERROR: usb_control_msg%s: ", usb_strerror());
|
309 |
|
310 | for(i=0; i<MAX_STREAM0x82; i++) // do once for setup
|
311 | if (usb_bulk_setup_async(g_Dev, &g_sPayload0x82[i].async, 0x82) < 0)
|
312 | abort("\nERROR: usb_bulk_setup_async: %s", usb_strerror());
|
313 |
|
314 | for(i=0; i<MAX_STREAM0x82; i++) // submit this transfer and returns immediately [25*BULK_OR_INTERRUPT_TRANSFERdown:-]
|
315 | if (usb_submit_async(g_sPayload0x82[i].async, &g_sPayload0x82[i].buff[0], BUFFLEN0x82) < 0)
|
316 | abort("\nERROR: usb_submit_async: %s", usb_strerror());
|
317 | }
|
318 |
|
319 | int xl80_read_loop_seq3()
|
320 | {
|
321 | int ret;
|
322 | g_iPayload0x82_index = NEXT_RING_INDEX(g_iPayload0x82_index, MAX_STREAM0x82); // next index
|
323 | if ((ret=usb_reap_async(g_sPayload0x82[g_iPayload0x82_index].async, 5000)) < 0)// [BULK_OR_INTERRUPT_TRANSFERback:xx xx xx ...]
|
324 | abort("\nERROR: usb_reap_async%s: ", usb_strerror());
|
325 | // submit this transfer and returns immediately
|
326 | if (usb_submit_async(g_sPayload0x82[g_iPayload0x82_index].async, &g_sPayload0x82[g_iPayload0x82_index].buff[0], BUFFLEN0x82) < 0) // [BULK_OR_INTERRUPT_TRANSFERdown:-]
|
327 | abort("\nERROR: usb_submit_async: %s", usb_strerror());
|
328 | return ret;
|
329 | }
|
330 |
|
331 | void xl80_post_loop_seq4()
|
332 | {
|
333 | char data[4096+4];
|
334 | // start of ending process BEFORE the last communication
|
335 | if(usb_control_msg(g_Dev, 0xa2, 0x03, 0x0000, 0x0082, data, 0x0002, 1000) < 0) // [CLASS_ENDPOINT:
|
336 | abort("\nERROR: usb_control_msg%s: ", usb_strerror());
|
337 |
|
338 | // ONE last async communication is needed
|
339 | xl80_read_loop_seq3();
|
340 | // skip payload evaluation and the async submit
|
341 |
|
342 | // normal ending process
|
343 | if (usb_control_msg(g_Dev, 0xa2, 0x04, 0x0000, 0x0082, data, 0x0008, 1000) < 0) // [CLASS_ENDPOINT:
|
344 | abort("\nERROR: usb_control_msg%s: ", usb_strerror());
|
345 | }
|
346 |
|
347 | void xl80_end_seq5()
|
348 | {
|
349 | if (usb_resetep(g_Dev, 0x82) < 0) // [ABORT_PIPEdown // 25*BULK_OR_INTERRUPT_TRANSFERback:- // ABORT_PIPEback // RESET_PIPE]
|
350 | abort("\nERROR: abort/reset 82%s", usb_strerror());
|
351 | if (usb_resetep(g_Dev, 0x81) < 0) // [ABORT_PIPE // RESET_PIPE]
|
352 | abort("\nERROR: abort/reset 81%s", usb_strerror());
|
353 | if (usb_resetep(g_Dev, 0x01) < 0) // [ABORT_PIPE // RESET_PIPE]
|
354 | abort("\nERROR: abort/reset 01%s", usb_strerror());
|
355 | }
|
356 |
|
357 | // usb_release_interface(g_Dev, 0);
|
358 | // usb_close(g_Dev);
|