forked from Simpleyyt/libfunction_so_usb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunction.c
851 lines (741 loc) · 17.5 KB
/
function.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <libusb.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <termios.h>
#include <errno.h>
#include "function.h"
#include "define.h"
#define DATALEN 0x100
#define FALSE -1
#define TRUE 0
unsigned char Data[DATALEN] = {1};
unsigned char *Buffer = &Data[8];
int p = 1;
libusb_device_handle *devs;
void closeCom(void)
{
int result;
if (devs == 0)
return;
result = libusb_release_interface (devs, 0);
if (result != 0)
{
fprintf (stderr, "libusb release interface failed\n");
}
libusb_close(devs);
libusb_exit(NULL);
devs = 0;
}
int openCom(void)
{
int result;
if (devs != 0)
return TRUE;
result = libusb_init(NULL);
if (result < 0)
{
fprintf(stderr, "libusb init error!\n");
return FALSE;
}
devs = libusb_open_device_with_vid_pid(NULL, PID, VID);
if( devs==NULL )
{
fprintf(stderr, "libusb open failed!\n");
return FALSE;
}
result = libusb_reset_device(devs);
if (result != 0)
{
fprintf(stderr, "libusb reset failed!\n");
closeCom();
return FALSE;
}
result = libusb_set_configuration (devs, 1);
if (result != 0)
{
fprintf (stderr, "libusb set configuration failed\n");
closeCom();
return FALSE;
}
result = libusb_claim_interface (devs, 0);
if (result != 0)
{
fprintf (stderr, "libusb claim interface failed\n");
closeCom();
return FALSE;
}
return TRUE;
}
void copyData(unsigned char *s, int spos, unsigned char *d, int dpos, int len)
{
int i;
for (i=0;i<len;i++)
{
d[i+dpos] = s[i+spos];
}
}
int checkData(unsigned char *data, int h, int t)
{
int check;
int i;
check = data[h];
for (i=h+1;i<=t;i++)
{
check = check^data[i];
}
return check;
}
void writeBuffer(unsigned char data)
{
Buffer[p] = data;
p++;
}
void writeBuffers(unsigned char *data, int length)
{
int i;
for (i=0;i<length;i++)
writeBuffer(data[i]);
}
void clearBuffer(void)
{
int i;
Data[0] = 0x01;
for (i=1;i<8;i++)
Data[i] = 0x00;
p = 0;
}
int writeCom(unsigned char *data, int length)
{
int receive;
data[6] = length;
receive = libusb_control_transfer(devs,
LIBUSB_RECIPIENT_INTERFACE|LIBUSB_REQUEST_TYPE_CLASS|LIBUSB_ENDPOINT_OUT,
LIBUSB_REQUEST_SET_CONFIGURATION,
0x301,
0,
data,
length+8,
500);
if (receive == LIBUSB_ERROR_TIMEOUT)
{
fprintf (stderr, "writeCom: timed out\n");
} else if (receive == LIBUSB_ERROR_PIPE)
{
fprintf (stderr, "writeCom: request not supported by target\n");
} else if (receive == LIBUSB_ERROR_NO_DEVICE)
{
fprintf (stderr, "writeCom: no device\n");
}
if(receive<0 || receive!=(length + 8))
{
closeCom();
return -1;
}
return length;
}
int readCom(unsigned char *data, int length)
{
int receive;
receive = libusb_control_transfer(devs,
LIBUSB_RECIPIENT_INTERFACE|LIBUSB_REQUEST_TYPE_CLASS|LIBUSB_ENDPOINT_IN,
LIBUSB_REQUEST_CLEAR_FEATURE,
0x302,
0,
data,
DATALEN,
500);
if (receive == LIBUSB_ERROR_TIMEOUT)
{
fprintf (stderr, "readCom: timed out\n");
} else if (receive == LIBUSB_ERROR_PIPE)
{
fprintf (stderr, "readCom: request not supported by target\n");
} else if (receive == LIBUSB_ERROR_NO_DEVICE)
{
fprintf (stderr, "readCom: no device\n");
}
if(receive<0)
{
closeCom();
return -1;
}
return receive-8;
}
int sendData(void)
{
int length;
int i;
printf ("Send data:");
for (i=0;i<p;i++)
fprintf(stderr, "%02x ",Buffer[i]);
fprintf(stderr, "\n");
if(openCom() == FALSE)
{
return FALSE;
}
length = writeCom(Data, p);
fprintf(stderr, "length send: %02x\n", length);
if(length != p)
return 0x05;
length=readCom(Data,248);
fprintf(stderr, "length read: %02x\n", length);
/*
if(length != receive_len)
return 0x05;*/
p = length;
fprintf(stderr, "Receive data:");
for (i=0;i<length;i++)
fprintf(stderr, "%02x ",Buffer[i]);
fprintf(stderr, "\n");
if(p<6 || (Buffer[0]!=0x02 && Buffer[0]!=STX) || (Buffer[p-1]!=0x03 && Buffer[p-1]!=ETX) || Buffer[2]+5!=p)
return 0x05;
if (checkData(Buffer,1,p-3) != Buffer[p-2])
return 0x02;
return 0;
}
int sendCommand(int command, unsigned char *sDATA, int sDLen,unsigned char *rDATA, int*Statue)
{
int result;
int BCC;
clearBuffer();
writeBuffer(STX);
writeBuffer(0x00);
writeBuffer(sDLen+1);
writeBuffer(command);
writeBuffers(sDATA, sDLen);
BCC = checkData(Buffer,1, p-1);
writeBuffer(BCC);
writeBuffer(ETX);
result = sendData();
if(result != 0)
return result;
copyData(Buffer,4,rDATA,0,Buffer[2]-1);
*Statue = Buffer[3];
return 0;
}
int API_SetSerNum( unsigned char *newValue, unsigned char *buffer)
{
int Statue;
int result = sendCommand(SetSerlNum,newValue,8,buffer,&Statue);
if (result != 0)
return result;
return Statue;
}
int API_GetSerNum(unsigned char *buffer)
{
int Statue;
int result = sendCommand(GetSerlNum,NULL,0,buffer,&Statue);
if (result != 0)
return result;
return Statue;
}
int WriteUserInfo(int num_blk, int num_length, char *user_info)
{
int Statue;
unsigned char DATA[121];
DATA[0] = num_blk;
DATA[1] = num_length;
copyData((unsigned char*)user_info, 0, DATA, 2, num_length);
int result = sendCommand(Write_UserInfo,DATA,num_length+2,(unsigned char*)user_info,&Statue);
if (result != 0)
return result;
return Statue;
}
int ReadUserInfo(int num_blk, int num_length, char *user_info)
{
int Statue;
unsigned char DATA[2];
DATA[0] = num_blk;
DATA[1] = num_length;
int result = sendCommand(Read_UserInfo,DATA,2,(unsigned char*)user_info,&Statue);
if (result != 0)
return result;
return Statue;
}
int GetVersionNum(char *VersionNum)
{
int Statue;
int result = sendCommand(Get_VersionNum,NULL,0,(unsigned char*)VersionNum,&Statue);
if (result != 0)
return result;
return Statue;
}
int API_ControlLED(unsigned char freq, unsigned char duration, unsigned char *buffer)
{
int Statue;
unsigned char DATA[2];
DATA[0] = freq;
DATA[1] = duration;
int result = sendCommand(Control_Led2,DATA,2,buffer,&Statue);
if (result != 0)
return result;
return Statue;
}
int API_ControlBuzzer(unsigned char freq, unsigned char duration, unsigned char *buffer)
{
int Statue;
unsigned char DATA[2];
DATA[0] = freq;
DATA[1] = duration;
int result = sendCommand(Control_Buzzer,DATA,2,buffer,&Statue);
if (result != 0)
return result;
return Statue;
}
int MF_Request( unsigned char inf_mode, unsigned char *buffer)
{
int Statue;
/*
unsigned char DATA[1];
if (inf_mode == 0x00)
DATA[0] = 0x52;
else
DATA[0] = 0x26;
*/
int result = sendCommand(REQA,&inf_mode,1,buffer,&Statue);
if (result != 0)
return result;
return Statue;
}
int MF_Anticoll(unsigned char *snr,unsigned char *status)
{
int Statue;
unsigned char DATA[5];
int result = sendCommand(Anticoll_A,NULL,0,DATA,&Statue);
if (result != 0)
return result;
*status = DATA[0];
copyData(DATA, 1, snr, 0, 4);
return Statue;
}
int MF_Select(unsigned char *snr)
{
int Statue;
int result = sendCommand(Select_A,snr,4,snr,&Statue);
if (result != 0)
return result;
return Statue;
}
int MF_Halt()
{
int Statue;
unsigned char error;
int result = sendCommand(Halt_A,NULL,0,&error,&Statue);
if (result != 0)
return result;
return Statue;
}
int API_PCDRead(unsigned char mode, unsigned char blk_add, unsigned char num_blk, unsigned char *snr, unsigned char *buffer)
{
int Statue;
const int num = (num_blk * 16 + 4) > 9? (num_blk*16+4):9;
unsigned char DATA[num];
DATA[0] = mode;
DATA[1] = num_blk;
DATA[2] = blk_add;
copyData(snr,0,DATA,3,6);
int result = sendCommand(MF_Read,DATA,9,DATA,&Statue);
if (result != 0)
return result;
copyData(DATA,0,snr,0,4);
copyData(DATA,4,buffer,0,num_blk*16);
return Statue;
}
int API_PCDWrite(unsigned char mode, unsigned char blk_add, unsigned char num_blk, unsigned char *snr, unsigned char *buffer)
{
int Statue;
const int num = num_blk * 16 + 9;
unsigned char DATA[num];
DATA[0] = mode;
DATA[1] = num_blk;
DATA[2] = blk_add;
copyData(snr,0,DATA,3,6);
copyData(buffer,0,DATA,9,num - 9);
int result = sendCommand(MF_Write,DATA,num,DATA,&Statue);
if (result != 0)
return result;
copyData(DATA,0,snr,0,4);
return Statue;
}
int API_PCDInitVal(unsigned char mode, unsigned char SectNum, unsigned char *snr, unsigned char *value)
{
int Statue;
unsigned char DATA[12];
DATA[0] = mode;
DATA[1] = SectNum;
copyData(snr,0,DATA,2,6);
copyData(value,0,DATA,8,4);
int result = sendCommand(MF_InitVal,DATA,12,DATA,&Statue);
if (result != 0)
return result;
copyData(DATA,0,snr,0,4);
return Statue;
}
int API_PCDDec(unsigned char mode, unsigned char SectNum, unsigned char *snr, unsigned char *value)
{
int Statue;
unsigned char DATA[12];
DATA[0] = mode;
DATA[1] = SectNum;
copyData(snr,0,DATA,2,6);
copyData(value,0,DATA,8,4);
int result = sendCommand(MF_Decrement,DATA,12,DATA,&Statue);
if (result != 0)
return result;
copyData(DATA,0,snr,0,4);
copyData(DATA,4,value,0,4);
return Statue;
}
int API_PCDInc(unsigned char mode, unsigned char SectNum, unsigned char *snr, unsigned char *value)
{
int Statue;
unsigned char DATA[12];
DATA[0] = mode;
DATA[1] = SectNum;
copyData(snr,0,DATA,2,6);
copyData(value,0,DATA,8,4);
int result = sendCommand(MF_Increment,DATA,12,DATA,&Statue);
if (result != 0)
return result;
copyData(DATA,0,snr,0,4);
copyData(DATA,4,value,0,4);
return Statue;
}
int GET_SNR(unsigned char mode, unsigned char API_halt, unsigned char *snr, unsigned char*value)
{
int Statue;
unsigned char DATA[5];
DATA[0] = mode;
DATA[1] = API_halt;
int result = sendCommand(MF_GET_SNR,DATA,2,DATA,&Statue);
if (result != 0)
return result;
snr[0] = DATA[0];
copyData(DATA,1,value,0,4);
return Statue;
}
int MF_Restore(unsigned char mode, int cardlength, unsigned char*carddata )
{
int Statue;
const int num = cardlength+2;
unsigned char DATA[num];
DATA[0] = mode;
DATA[1] = cardlength;
copyData(carddata, 0, DATA, 2, cardlength);
int result = sendCommand(ISO14443_TypeA_Transfer_Command,DATA,num,carddata,&Statue);
if (result != 0)
return result;
return Statue;
}
int RequestType_B(unsigned char *buffer)
{
int Statue;
int result = sendCommand(ReqB,NULL,0,buffer,&Statue);
if (result != 0)
return result;
return Statue;
}
int AntiType_B(unsigned char *buffer)
{
int Statue;
int result = sendCommand(AnticollB,NULL,0,buffer,&Statue);
if (result != 0)
return result;
return Statue;
}
int SelectType_B(unsigned char*SerialNum)
{
int Statue;
int result = sendCommand(Attrib_TypeB,SerialNum,4,SerialNum,&Statue);
if (result != 0)
return result;
return Statue;
}
int Request_AB(unsigned char* buffer)
{
int Statue;
int result = sendCommand(Rst_TypeB,buffer,4,buffer,&Statue);
if (result != 0)
return result;
return Statue;
}
int API_ISO14443TypeBTransCOSCmd(unsigned char *cmd, int cmdSize, unsigned char *buffer)
{
int Statue;
unsigned char DATA[256];
DATA[0] = cmdSize;
copyData(buffer, 0, DATA, 1 ,cmdSize);
int result = sendCommand(ISO14443_TypeB_Transfer_Command,buffer,cmdSize+1,buffer,&Statue);
if (result != 0)
return result;
return Statue;
}
int API_ISO15693_Inventory(unsigned char flag, unsigned char afi, unsigned char *pData, unsigned char *nrOfCard, unsigned char *pBuffer)
{
int Statue;
unsigned char DATA[256];
DATA[0] = flag;
DATA[1] = afi;
DATA[2] = 0;
copyData(pData, 0, DATA, 3 ,8);
int result = sendCommand(ISO14443_TypeB_Transfer_Command,DATA,11,DATA,&Statue);
if (result != 0)
return result;
*nrOfCard = DATA[0];
copyData(DATA,1,pBuffer,0,8*DATA[0]);
return Statue;
}
int API_ISO15693Read(unsigned char flags, unsigned char blk_add, unsigned char num_blk, unsigned char *uid, unsigned char *buffer)
{
int Statue;
int num;
unsigned char DATA[11];
DATA[0] = flags;
DATA[1] = blk_add;
DATA[2] = num_blk;
num = 3;
if (flags == 0x22)
{
copyData(uid, 0, DATA, 3 ,8);
num = 11;
}
int result = sendCommand(ISO15693_Read,DATA,num,buffer,&Statue);
if (result != 0)
return result;
return Statue;
}
int API_ISO15693Write(unsigned char flags, unsigned char blk_add, unsigned char num_blk, unsigned char *uid, unsigned char *data)
{
int Statue;
int num, k;
unsigned char DATA[256];
k = 4;
DATA[0] = flags;
DATA[1] = blk_add;
DATA[2] = num_blk;
num = num_blk*k + 3;
if (flags == 0x22)
{
copyData(uid, 0, DATA, 3 ,8);
num = num_blk*k + 11;
}
copyData(data,0,DATA,3,num_blk*4);
int result = sendCommand(ISO15693_Write,DATA,num,data,&Statue);
if (result != 0)
return result;
return Statue;
}
int API_ISO15693Lock(unsigned char flags, unsigned char num_blk, unsigned char *uid, unsigned char *buffer)
{
int Statue;
int num;
unsigned char DATA[10];
DATA[0] = flags;
DATA[1] = num_blk;
num = 2;
if (flags == 0x22)
{
copyData(uid, 0, DATA, 2 ,8);
num = 10;
}
int result = sendCommand(ISO15693_Lockblock,DATA,num,buffer,&Statue);
if (result != 0)
return result;
return Statue;
}
int API_ISO15693StayQuiet(unsigned char flags, unsigned char *uid, unsigned char *buffer)
{
int Statue;
unsigned char DATA[9];
DATA[0] = flags;
copyData(uid, 0, DATA, 1 ,8);
int result = sendCommand(ISO15693_StayQuiet,DATA,9,buffer,&Statue);
if (result != 0)
return result;
return Statue;
}
int API_ISO15693Select(unsigned char flags, unsigned char *uid, unsigned char *buffer)
{
int Statue;
unsigned char DATA[9];
DATA[0] = flags;
copyData(uid, 0, DATA, 1 ,8);
int result = sendCommand(ISO15693_Select,DATA,9,buffer,&Statue);
if (result != 0)
return result;
return Statue;
}
int API_ResetToReady(unsigned char flags, unsigned char *uid, unsigned char *buffer)
{
int Statue;
int num;
unsigned char DATA[9];
DATA[0] = flags;
num = 1;
if (flags == 0x22)
{
copyData(uid, 0, DATA, 1 ,8);
num = 9;
}
int result = sendCommand(ISO15693_Resetready,DATA,num,buffer,&Statue);
if (result != 0)
return result;
return Statue;
}
int API_WriteAFI(unsigned char flags, unsigned char afi, unsigned char *uid, unsigned char *buffer)
{
int Statue;
int num;
unsigned char DATA[10];
DATA[0] = flags;
DATA[1] = afi;
num = 2;
if (flags == 0x22)
{
copyData(uid, 0, DATA, 2 ,8);
num = 10;
}
int result = sendCommand(ISO15693_Write_Afi,DATA,num,buffer,&Statue);
if (result != 0)
return result;
return Statue;
}
int API_LockAFI(unsigned char flags, unsigned char *uid, unsigned char *buffer)
{
int Statue;
int num;
unsigned char DATA[9];
DATA[0] = flags;
num = 1;
if (flags == 0x22)
{
copyData(uid, 0, DATA, 1 ,8);
num = 9;
}
int result = sendCommand(ISO15693_Lock_Afi,DATA,num,buffer,&Statue);
if (result != 0)
return result;
return Statue;
}
int API_WriteDSFID(unsigned char flags, unsigned char DSFID, unsigned char *uid, unsigned char *buffer)
{
int Statue;
int num;
unsigned char DATA[10];
DATA[0] = flags;
DATA[1] = DSFID;
num = 2;
if (flags == 0x22)
{
copyData(uid, 0, DATA, 2 ,8);
num = 10;
}
int result = sendCommand(ISO15693_Write_Dsfid,DATA,num,buffer,&Statue);
if (result != 0)
return result;
return Statue;
}
int API_LockDSFID(unsigned char flags, unsigned char *uid, unsigned char *buffer )
{
int Statue;
int num;
unsigned char DATA[9];
DATA[0] = flags;
num = 1;
if (flags == 0x22)
{
copyData(uid, 0, DATA, 1 ,8);
num = 9;
}
int result = sendCommand(ISO15693_Lock_Dsfid,DATA,num,buffer,&Statue);
if (result != 0)
return result;
return Statue;
}
int API_ISO15693_GetSysInfo(unsigned char flags, unsigned char *uid, unsigned char *buffer)
{
int Statue;
int num;
unsigned char DATA[9];
DATA[0] = flags;
num = 1;
if (flags == 0x22)
{
copyData(uid, 0, DATA, 1 ,8);
num = 9;
}
int result = sendCommand(ISO15693_Get_Information,DATA,num,buffer,&Statue);
if (result != 0)
return result;
return Statue;
}
int API_ISO15693_GetMulSecurity(unsigned char flags, unsigned char blkAddr, unsigned char blkNum, unsigned char *uid, unsigned char *pBuffer)
{
int Statue;
int num;
unsigned char DATA[11];
DATA[0] = flags;
DATA[1] = blkAddr;
DATA[2] = blkNum;
num = 3;
if (flags == 0x22)
{
copyData(uid, 0, DATA, 3 ,8);
num = 11;
}
int result = sendCommand(ISO15693_Get_Multiple_Block_Security,DATA,num,pBuffer,&Statue);
if (result != 0)
return result;
return Statue;
}
int API_ISO15693TransCOSCmd(unsigned char *cmd, int cmdSize, unsigned char *buffer)
{
int Statue;
unsigned char DATA[256];
DATA[0] = cmdSize;
copyData(buffer,0,DATA,1,cmdSize);
int result = sendCommand(ISO15693_Transfer_Command,DATA,cmdSize,buffer,&Statue);
if (result != 0)
return result;
return Statue;
}
int UL_HLRead(unsigned char mode, unsigned char blk_add, unsigned char *snr, unsigned char *buffer)
{
int Statue;
unsigned char DATA[23];
DATA[0] = mode;
DATA[1] = blk_add;
int result = sendCommand(CMD_UL_HLRead,DATA,2,DATA,&Statue);
if (result != 0)
return result;
copyData(DATA,0,buffer,0,16);
copyData(DATA,16,snr,0,7);
return Statue;
}
int UL_HLWrite(unsigned char mode, unsigned char blk_add, unsigned char *snr, unsigned char *buffer)
{
int Statue;
unsigned char DATA[7];
DATA[0] = mode;
DATA[1] = 1;
DATA[2] = blk_add;
copyData(buffer, 0, DATA, 3, 4);
int result = sendCommand(CMD_UL_HLWrite,DATA,7,snr,&Statue);
if (result != 0)
return result;
return Statue;
}
int UL_Request(unsigned char mode,unsigned char *snr)
{
int Statue;
unsigned char DATA[1];
DATA[0] = mode;
int result = sendCommand(CMD_UL_Request,DATA,1,snr,&Statue);
if (result != 0)
return result;
return Statue;
}