FreeCalypso > hg > freecalypso-sw
comparison rvinterf/old/packettx.c @ 173:f42854da4563
rvinterf: beginning of refactoring
| author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
|---|---|
| date | Fri, 22 Nov 2013 05:56:07 +0000 |
| parents | rvinterf/packettx.c@4d8e4c58df71 |
| children |
comparison
equal
deleted
inserted
replaced
| 172:019120585a1c | 173:f42854da4563 |
|---|---|
| 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 } |
