comparison rvinterf/old/before-rvinterf/packettx.c @ 0:e7502631a0f9

initial import from freecalypso-sw rev 1033:5ab737ac3ad7
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 11 Jun 2016 00:13:35 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:e7502631a0f9
1 /*
2 * This module handles the lowest level of serial packet Tx
3 */
4
5 #include <sys/types.h>
6 #include <stdio.h>
7 #include <stdlib.h>
8 #include <unistd.h>
9 #include "pktmux.h"
10 #include "txpkt.h"
11
12 extern int target_fd;
13
14 send_pkt_to_target(pkt, pktlen)
15 u_char *pkt;
16 {
17 u_char buf[MAX_PKT_TO_TARGET*2+2];
18 u_char *cp, *dp, *endp;
19 int c;
20
21 endp = pkt + pktlen;
22 dp = buf;
23 *dp++ = STX;
24 for (cp = pkt; cp < endp; cp++) {
25 c = *cp;
26 if (c == STX || c == DLE)
27 *dp++ = DLE;
28 *dp++ = c;
29 }
30 *dp++ = STX;
31 write(target_fd, buf, dp - buf);
32 }