annotate rvinterf/old/packettx.c @ 920:7cb0b32f1997

fc-pirhackinit works after fixing MAX_MEMREAD_BYTES
author Space Falcon <falcon@ivan.Harhan.ORG>
date Tue, 08 Sep 2015 23:33:38 +0000
parents f42854da4563
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
171
4d8e4c58df71 rvtdump: implemented Tx extension hack, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
1 /*
4d8e4c58df71 rvtdump: implemented Tx extension hack, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
2 * This module handles the lowest level of serial packet Tx
4d8e4c58df71 rvtdump: implemented Tx extension hack, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
3 */
4d8e4c58df71 rvtdump: implemented Tx extension hack, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
4
4d8e4c58df71 rvtdump: implemented Tx extension hack, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
5 #include <sys/types.h>
4d8e4c58df71 rvtdump: implemented Tx extension hack, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
6 #include <stdio.h>
4d8e4c58df71 rvtdump: implemented Tx extension hack, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
7 #include <stdlib.h>
4d8e4c58df71 rvtdump: implemented Tx extension hack, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
8 #include <unistd.h>
4d8e4c58df71 rvtdump: implemented Tx extension hack, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
9 #include "pktmux.h"
4d8e4c58df71 rvtdump: implemented Tx extension hack, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
10 #include "txpkt.h"
4d8e4c58df71 rvtdump: implemented Tx extension hack, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
11
4d8e4c58df71 rvtdump: implemented Tx extension hack, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
12 extern int target_fd;
4d8e4c58df71 rvtdump: implemented Tx extension hack, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
13
4d8e4c58df71 rvtdump: implemented Tx extension hack, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
14 send_pkt_to_target(pkt, pktlen)
4d8e4c58df71 rvtdump: implemented Tx extension hack, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
15 u_char *pkt;
4d8e4c58df71 rvtdump: implemented Tx extension hack, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
16 {
4d8e4c58df71 rvtdump: implemented Tx extension hack, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
17 u_char buf[MAX_PKT_TO_TARGET*2+2];
4d8e4c58df71 rvtdump: implemented Tx extension hack, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
18 u_char *cp, *dp, *endp;
4d8e4c58df71 rvtdump: implemented Tx extension hack, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
19 int c;
4d8e4c58df71 rvtdump: implemented Tx extension hack, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
20
4d8e4c58df71 rvtdump: implemented Tx extension hack, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
21 endp = pkt + pktlen;
4d8e4c58df71 rvtdump: implemented Tx extension hack, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
22 dp = buf;
4d8e4c58df71 rvtdump: implemented Tx extension hack, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
23 *dp++ = STX;
4d8e4c58df71 rvtdump: implemented Tx extension hack, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
24 for (cp = pkt; cp < endp; cp++) {
4d8e4c58df71 rvtdump: implemented Tx extension hack, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
25 c = *cp;
4d8e4c58df71 rvtdump: implemented Tx extension hack, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
26 if (c == STX || c == DLE)
4d8e4c58df71 rvtdump: implemented Tx extension hack, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
27 *dp++ = DLE;
4d8e4c58df71 rvtdump: implemented Tx extension hack, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
28 *dp++ = c;
4d8e4c58df71 rvtdump: implemented Tx extension hack, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
29 }
4d8e4c58df71 rvtdump: implemented Tx extension hack, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
30 *dp++ = STX;
4d8e4c58df71 rvtdump: implemented Tx extension hack, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
31 write(target_fd, buf, dp - buf);
4d8e4c58df71 rvtdump: implemented Tx extension hack, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
32 }