zcore.c
20.7 KB
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
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
/*
* File : rz.c
* the core functions of implementing zmodem protocol
* Change Logs:
* Date Author Notes
* 2011-03-29 itspy
*/
#include <rtthread.h>
#include <finsh.h>
#include <shell.h>
#include <rtdef.h>
#include <dfs.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/statfs.h>
#include <stdio.h>
#include "zdef.h"
char ZF0_CMD; /* file conversion request */
char ZF1_CMD; /* file management request */
char ZF2_CMD; /* file transport request */
char ZF3_CMD;
rt_uint8_t Rxframeind; /* ZBIN ZBIN32, or ZHEX type of frame */
rt_uint16_t Rxcount; /* received count*/
char header_type; /* header type */
rt_uint8_t rx_header[4]; /* received header */
rt_uint8_t tx_header[4]; /* transmitted header */
rt_uint32_t Rxpos; /* received file position */
rt_uint32_t Txpos; /* transmitted file position */
rt_uint8_t Txfcs32; /* TURE means send binary frames with 32 bit FCS */
rt_uint8_t TxCRC; /* controls 32 bit CRC being sent */
rt_uint8_t RxCRC; /* indicates/controls 32 bit CRC being received */
/* 0 == CRC16, 1 == CRC32, 2 == CRC32 + RLE */
char Attn[ZATTNLEN+1]; /* attention string rx sends to tx on err */
void zinit_parameter(void);
void zsend_bin_header(rt_uint8_t type, rt_uint8_t *hdr);
void zsend_hex_header(rt_uint8_t type, rt_uint8_t *hdr);
void zsend_bin_data(rt_uint8_t *buf, rt_int16_t len, rt_uint8_t frameend);
static rt_int16_t zrec_data16(rt_uint8_t *buf, rt_uint16_t len);
static rt_int16_t zrec_data32(rt_uint8_t *buf, rt_int16_t len);
static rt_int16_t zrec_data32r(rt_uint8_t *buf, rt_int16_t len);
rt_int16_t zget_data(rt_uint8_t *buf, rt_uint16_t len);
rt_int16_t zget_header(rt_uint8_t *hdr);
static rt_int16_t zget_bin_header(rt_uint8_t *hdr);
static rt_int16_t zget_bin_fcs(rt_uint8_t *hdr);
rt_int16_t zget_hex_header(rt_uint8_t *hdr);
static void zsend_ascii(rt_uint8_t c);
void zsend_zdle_char(rt_uint16_t ch);
static rt_int16_t zget_hex(void);
rt_int16_t zread_byte(void);
rt_int16_t zxor_read(void);
void zput_pos(rt_uint32_t pos);
void zget_pos(rt_uint32_t pos);
void zinit_parameter(void)
{
rt_uint8_t i;
ZF0_CMD = CANFC32|CANFDX|CANOVIO; /* not chose CANFC32,CANRLE,although it have been supported */
ZF1_CMD = 0; /* fix header length,not support CANVHDR */
ZF2_CMD = 0;
ZF3_CMD = 0;
Rxframeind =0;
header_type = 0;
Rxcount = 0;
for (i=0;i<4;i++) rx_header[i] = tx_header[i] = 0;
Rxpos = Txpos = 0;
RxCRC = 0;
Txfcs32 = 0;
return ;
}
/* send binary header */
void zsend_bin_header(rt_uint8_t type, rt_uint8_t *hdr)
{
rt_uint8_t i;
rt_uint32_t crc;
zsend_byte(ZPAD);
zsend_byte(ZDLE);
TxCRC = Txfcs32;
if (TxCRC == 0)
{
zsend_byte(ZBIN);
zsend_zdle_char(type);
/* add 16bits crc */
crc = 0L;
crc = updcrc16(type, 0);
for (i=0;i<4;i++)
{
zsend_zdle_char(*hdr);
crc = updcrc16((0377 & *hdr++),crc);
}
crc = updcrc16(0,updcrc16(0,crc));
zsend_zdle_char(((int)(crc>>8)));
zsend_zdle_char(crc);
}
else if(TxCRC == 1)
{
zsend_byte(ZBIN32);
zsend_zdle_char(type);
/* add 32bits crc */
crc = 0xffffffffL;
crc = updcrc32(type, crc);
for (i=0;i<4;i++)
{
zsend_zdle_char(*hdr);
crc = updcrc32((0377 & *hdr++), crc);
}
crc = ~crc;
for (i=0; i<4;i++)
{
zsend_zdle_char(crc);
crc >>= 8;
}
}
else if (TxCRC == 2)
{
zsend_byte(ZBINR32);
zsend_zdle_char(type);
/* add 32bits crc */
crc = 0xffffffffL;
crc = updcrc32(type, crc);
for (i=0;i<4;i++)
{
zsend_zdle_char(*hdr);
crc = updcrc32((0377 & *hdr++), crc);
}
crc = ~crc;
for (i=0; i<4;i++)
{
zsend_zdle_char(crc);
crc >>= 8;
}
}
return;
}
/* send hex header */
void zsend_hex_header(rt_uint8_t type, rt_uint8_t *hdr)
{
rt_uint8_t i;
rt_uint16_t crc;
zsend_line(ZPAD); zsend_line(ZPAD); zsend_line(ZDLE);
zsend_line(ZHEX);
zsend_ascii(type);
crc = updcrc16(type, 0);
for (i=0; i<4; i++)
{
zsend_ascii(*hdr);
crc = updcrc16((0377 & *hdr++), crc);
}
crc = updcrc16(0,updcrc16(0,crc));
zsend_ascii(crc>>8);
zsend_ascii(crc);
/* send display control cmd */
zsend_line(015); zsend_line(0212);
if (type != ZFIN && type != ZACK)
zsend_line(021);
TxCRC = 0; /* clear tx crc type */
return;
}
/* send binary data,with frameend */
void zsend_bin_data(rt_uint8_t *buf, rt_int16_t len, rt_uint8_t frameend)
{
rt_int16_t i,c,tmp;
rt_uint32_t crc;
if (TxCRC == 0) /* send binary data with 16bits crc check */
{
crc = 0x0L;
for (i=0;i<len;i++)
{
zsend_zdle_char(*buf);
crc = updcrc16((0377 & *buf++), crc);
}
zsend_byte(ZDLE); zsend_byte(frameend);
crc = updcrc16(frameend, crc);
crc = updcrc16(0,updcrc16(0,crc));
zsend_zdle_char(crc>>8);
zsend_zdle_char(crc);
}
else if (TxCRC == 1) /* send binary data with 32 bits crc check */
{
crc = 0xffffffffL;
for (i=0;i<len;i++)
{
c = *buf++ & 0377;
zsend_zdle_char(c);
crc = updcrc32(c, crc);
}
zsend_byte(ZDLE); zsend_byte(frameend);
crc = updcrc32(frameend, crc);
crc = ~crc;
for (i=0;i<4;i++)
{
zsend_zdle_char((int)crc); crc >>= 8;
}
}
else if (TxCRC == 2) /* send binary data with 32bits crc check,RLE encode */
{
crc = 0xffffffffL;
tmp = *buf++ & 0377;
for (i = 0; --len >= 0; ++buf)
{
if ((c = *buf & 0377) == tmp && i < 126 && len>0)
{
++i; continue;
}
if (i==0)
{
zsend_zdle_char(tmp);
crc = updcrc32(tmp, crc);
if (tmp == ZRESC)
{
zsend_zdle_char(0100); crc = updcrc32(0100, crc);
}
tmp = c;
}
else if (i == 1)
{
if (tmp != ZRESC)
{
zsend_zdle_char(tmp); zsend_zdle_char(tmp);
crc = updcrc32(tmp, crc);
crc = updcrc32(tmp, crc);
i = 0; tmp = c;
}
}
else
{
zsend_zdle_char(ZRESC); crc = updcrc32(ZRESC, crc);
if (tmp == 040 && i < 34)
{
i += 036;
zsend_zdle_char(i);
crc = updcrc32(i, crc);
}
else
{
i += 0101;
zsend_zdle_char(i); crc = updcrc32(i, crc);
zsend_zdle_char(tmp); crc = updcrc32(tmp, crc);
}
i = 0; tmp = c;
}
}
zsend_byte(ZDLE); zsend_byte(frameend);
crc = updcrc32(frameend, crc);
crc = ~crc;
for (i=0;i<4;i++)
{
zsend_zdle_char(crc);
crc >>= 8;
}
}
if (frameend == ZCRCW)
zsend_byte(XON);
return;
}
/* receive data,with 16bits CRC check */
static rt_int16_t zrec_data16(rt_uint8_t *buf, rt_uint16_t len)
{
rt_int16_t c,crc_cnt;
rt_uint16_t crc;
rt_err_t res = -RT_ERROR;
rt_uint8_t *p,flag = 0;
p = buf;
crc_cnt = 0; crc = 0L;
Rxcount = 0;
while(buf <= p+len)
{
if ((res = zread_byte()) & ~0377)
{
if (res == GOTCRCE || res == GOTCRCG ||
res == GOTCRCQ || res == GOTCRCW)
{
c = res;
c = res;
crc = updcrc16(res&0377, crc);
flag = 1;
continue;
}
else if (res == GOTCAN) return ZCAN;
else if (res == TIMEOUT) return TIMEOUT;
else return res;
}
else
{
if (flag)
{
crc = updcrc16(res, crc);
crc_cnt++;
if (crc_cnt < 2) continue;
if ((crc & 0xffff))
{
#ifdef ZDEBUG
rt_kprintf("error code: CRC16 error \r\n");
#endif
return -RT_ERROR;
}
return c;
}
else
{
*buf++ = res;
Rxcount++;
crc = updcrc16(res, crc);
}
}
}
return -RT_ERROR;
}
/* receive data,with 32bits CRC check */
static rt_int16_t zrec_data32(rt_uint8_t *buf, rt_int16_t len)
{
rt_int16_t c,crc_cnt;
rt_uint32_t crc;
rt_err_t res = -RT_ERROR;
rt_uint8_t *p,flag = 0;
crc_cnt = 0; crc = 0xffffffffL;
Rxcount = 0;
while (buf <= p+len)
{
if ((res = zread_byte()) & ~0377)
{
if (res == GOTCRCE || res == GOTCRCG ||
res == GOTCRCQ || res == GOTCRCW)
{
c = res;
crc = updcrc32(res&0377, crc);
flag = 1;
continue;
}
else if (res == GOTCAN) return ZCAN;
else if (res == TIMEOUT) return TIMEOUT;
else return res;
}
else
{
if (flag)
{
crc = updcrc32(res, crc);
crc_cnt++;
if (crc_cnt < 4) continue;
if ((crc & 0xDEBB20E3))
{
#ifdef ZDEBUG
rt_kprintf("error code: CRC32 error \r\n");
#endif
return -RT_ERROR;
}
return c;
}
else
{
*buf++ = res;
Rxcount++;
crc = updcrc32(res, crc);
}
}
}
return -RT_ERROR;
}
/* receive data,with RLE encoded,32bits CRC check */
static rt_int16_t zrec_data32r(rt_uint8_t *buf, rt_int16_t len)
{
rt_int16_t c,crc_cnt;
rt_uint32_t crc;
rt_err_t res = -RT_ERROR;
rt_uint8_t *p,flag = 0;
crc_cnt = 0; crc = 0xffffffffL;
Rxcount = 0;
p = buf;
while (buf <= p+len)
{
if ((res = zread_byte()) & ~0377)
{
if (res == GOTCRCE || res == GOTCRCG ||
res == GOTCRCQ || res == GOTCRCW)
{
c = res;
crc = updcrc32(res&0377, crc);
flag = 1;
continue;
}
else if (res == GOTCAN) return ZCAN;
else if (res == TIMEOUT) return TIMEOUT;
else return res;
}
else
{
if (flag)
{
crc = updcrc32(res, crc);
crc_cnt++;
if (crc_cnt < 4) continue;
if ((crc & 0xDEBB20E3))
{
#ifdef ZDEBUG
rt_kprintf("error code: CRC32 error \r\n");
#endif
return -RT_ERROR;
}
return c;
}
else
{
crc = updcrc32(res, crc);
switch (c)
{
case 0:
if (res == ZRESC)
{
c = -1; continue;
}
*buf++ = res;
Rxcount++;
continue;
case -1:
if (res >= 040 && res < 0100)
{
c = res - 035; res = 040;
goto spaces;
}
if (res == 0100)
{
c = 0;
*buf++ = ZRESC;
Rxcount++;
continue;
}
c = res; continue;
default:
c -= 0100;
if (c < 1)
goto end;
spaces:
if ((buf + c) > p+len)
goto end;
while ( --res >= 0)
{
*buf++ = res;
Rxcount++;
}
c = 0; continue;
}
}
} // if -else
}
end:
return -RT_ERROR;
}
rt_int16_t zget_data(rt_uint8_t *buf, rt_uint16_t len)
{
rt_int16_t res = -RT_ERROR;
if (RxCRC == 0)
{
res = zrec_data16(buf,len);
}
else if (RxCRC == 1)
{
res = zrec_data32(buf, len);
}
else if (RxCRC == 2)
{
res = zrec_data32r(buf, len);
}
return res;
}
/* get type and cmd of header, fix lenght */
rt_int16_t zget_header(rt_uint8_t *hdr)
{
rt_int16_t c,prev_char;
rt_uint32_t bit;
rt_uint16_t get_can,step_out;
bit = get_device_baud(); /* get console baud rate */
Rxframeind = header_type = 0;
step_out = 0;
prev_char = 0xff;
for (;;)
{
c = zread_line(100);
switch(c)
{
case 021:
case 0221:
if (prev_char == CAN) break;
if (prev_char == ZCRCW) goto start_again;
break;
case RCDO:
goto end;
case TIMEOUT:
if (prev_char == CAN) break;
if (prev_char == ZCRCW)
{
c = -RT_ERROR; goto end;
}
goto end;
case ZCRCW:
if (prev_char == CAN) goto start_again;
break;
case CAN:
get_can:
if (++get_can > 5)
{
c = ZCAN; goto end;
}
break;
case ZPAD:
if (prev_char == CAN) break;
if (prev_char == ZCRCW) goto start_again;
step_out = 1;
break;
default:
if (prev_char == CAN) break;
if (prev_char == ZCRCW) goto start_again;
start_again:
if (--bit == 0)
{
c = GCOUNT; goto end;
}
get_can = 0;
break;
}
prev_char = c;
if (step_out) break; /* exit loop */
}
step_out = get_can = 0;
for (;;)
{
c = zxor_read();
switch(c)
{
case ZPAD:
break;
case RCDO:
case TIMEOUT:
goto end;
case ZDLE:
step_out = 1;
break;
default:
goto start_again;
}
if (step_out) break;
}
Rxframeind = c = zxor_read();
switch (c)
{
case ZBIN32:
RxCRC = 1; c = zget_bin_fcs(hdr); break;
case ZBINR32:
RxCRC = 2; c = zget_bin_fcs(hdr); break;
case ZBIN:
RxCRC = 0; c = zget_bin_header(hdr); break;
case ZHEX:
RxCRC = 0; c = zget_hex_header(hdr); break;
case CAN:
goto get_can;
case RCDO:
case TIMEOUT:
goto end;
default:
goto start_again;
}
end:
return c;
}
/* receive a binary header */
static rt_int16_t zget_bin_header(rt_uint8_t *hdr)
{
rt_int16_t res, i;
rt_uint16_t crc;
if ((res = zread_byte()) & ~0377)
return res;
header_type = res;
crc = updcrc16(res, 0);
for (i=0;i<4;i++)
{
if ((res = zread_byte()) & ~0377)
return res;
crc = updcrc16(res, crc);
*hdr++ = res;
}
if ((res = zread_byte()) & ~0377)
return res;
crc = updcrc16(res, crc);
if ((res = zread_byte()) & ~0377)
return res;
crc = updcrc16(res, crc);
if (crc & 0xFFFF)
{
rt_kprintf("CRC error\n");
return -RT_ERROR;
}
return header_type;
}
/* receive a binary header,with 32bits FCS */
static rt_int16_t zget_bin_fcs(rt_uint8_t *hdr)
{
rt_int16_t res, i;
rt_uint32_t crc;
if ((res = zread_byte()) & ~0377)
return res;
header_type = res;
crc = 0xFFFFFFFFL;
crc = updcrc32(res, crc);
for (i=0;i<4;i++) /* 4headers */
{
if ((res = zread_byte()) & ~0377)
return res;
crc = updcrc32(res, crc);
*hdr++ = res;
}
for (i=0;i<4;i++) /* 4bytes crc */
{
if ((res = zread_byte()) & ~0377)
return res;
crc = updcrc32(res, crc);
}
if (crc != 0xDEBB20E3)
{
#ifdef ZDEBUG
rt_kprintf("CRC error\n");
#endif
return -RT_ERROR;
}
return header_type;
}
/* receive a hex style header (type and position) */
rt_int16_t zget_hex_header(rt_uint8_t *hdr)
{
rt_int16_t res,i;
rt_uint16_t crc;
if ((res = zget_hex()) < 0)
return res;
header_type = res;
crc = updcrc16(res, 0);
for (i=0;i<4;i++)
{
if ((res = zget_hex()) < 0)
return res;
crc = updcrc16(res, crc);
*hdr++ = res;
}
if ((res = zget_hex()) < 0)
return res;
crc = updcrc16(res, crc);
if ((res = zget_hex()) < 0)
return res;
crc = updcrc16(res, crc);
if (crc & 0xFFFF)
{
#ifdef ZDEBUG
rt_kprintf("error code : CRC error\r\n");
#endif
return -RT_ERROR;
}
res = zread_line(100);
if (res < 0)
return res;
res = zread_line(100);
if (res < 0)
return res;
return header_type;
}
/* convert to ascii */
static void zsend_ascii(rt_uint8_t c)
{
const char hex[] = "0123456789abcdef";
zsend_line(hex[(c&0xF0)>>4]);
zsend_line(hex[(c)&0xF]);
return;
}
/*
* aend character c with ZMODEM escape sequence encoding.
*/
void zsend_zdle_char(rt_uint16_t ch)
{
rt_uint16_t res;
res = ch & 0377;
switch (res)
{
case 0377:
zsend_byte(res);
break;
case ZDLE:
zsend_byte(ZDLE);
res ^= 0100;
zsend_byte(res);
break;
case 021:
case 023:
case 0221:
case 0223:
zsend_byte(ZDLE);
res ^= 0100;
zsend_byte(res);
break;
default:
zsend_byte(res);
}
}
/* decode two lower case hex digits into an 8 bit byte value */
static rt_int16_t zget_hex(void)
{
rt_int16_t res,n;
if ((res = zxor_read()) < 0)
return res;
n = res - '0';
if (n > 9)
n -= ('a' - ':');
if (n & ~0x0f)
return -RT_ERROR;
if ((res = zxor_read()) < 0)
return res;
res -= '0';
if (res > 9)
res -= ('a' - ':');
if (res & ~0x0f)
return -RT_ERROR;
res += (n<<4);
return res;
}
/*
* read a byte, checking for ZMODEM escape encoding
* including CAN*5 which represents a quick abort
*/
rt_int16_t zread_byte(void)
{
register int res;
again:
/* Quick check for non control characters */
if ((res = zread_line(100)) & 0140)
return res;
switch (res)
{
case ZDLE:
break;
case 023:
case 0223:
case 021:
case 0221:
goto again;
default:
return res;
}
again2:
if ((res = zread_line(100)) < 0)
return res;
if (res == CAN && (res = zread_line(100)) < 0)
return res;
if (res == CAN && (res = zread_line(100)) < 0)
return res;
if (res == CAN && (res = zread_line(100)) < 0)
return res;
switch (res)
{
case CAN:
return GOTCAN;
case ZCRCE:
case ZCRCG:
case ZCRCQ:
case ZCRCW:
return (res | GOTOR);
case ZRUB0:
return 0177;
case ZRUB1:
return 0377;
case 023:
case 0223:
case 021:
case 0221:
goto again2;
default:
if ((res & 0140) == 0100)
return (res ^ 0100);
break;
}
return -RT_ERROR;
}
/*
* @read a character from the modem line with timeout.
* @eat parity, XON and XOFF characters.
*/
rt_int16_t zxor_read(void)
{
rt_int16_t res;
for (;;)
{
if ((res = zread_line(100)) < 0)
return res;
switch (res &= 0177) {
case XON:
case XOFF:
continue;
case '\r':
case '\n':
case ZDLE:
default:
return res;
}
}
}
/* put file posistion into the header*/
void zput_pos(rt_uint32_t pos)
{
tx_header[ZP0] = pos;
tx_header[ZP1] = pos>>8;
tx_header[ZP2] = pos>>16;
tx_header[ZP3] = pos>>24;
return;
}
/* Recover a long integer from a header */
void zget_pos(rt_uint32_t pos)
{
Rxpos = (rx_header[ZP3] & 0377);
Rxpos = (Rxpos << 8) | (rx_header[ZP2] & 0377);
Rxpos = (Rxpos << 8) | (rx_header[ZP1] & 0377);
Rxpos = (Rxpos << 8) | (rx_header[ZP0] & 0377);
return;
}
/* end of zcore.c */