aboutsummaryrefslogtreecommitdiffstats
path: root/c/necho.c
diff options
context:
space:
mode:
Diffstat (limited to 'c/necho.c')
-rw-r--r--c/necho.c33
1 files changed, 1 insertions, 32 deletions
diff --git a/c/necho.c b/c/necho.c
index b9dc9d5..99551d4 100644
--- a/c/necho.c
+++ b/c/necho.c
@@ -1,38 +1,7 @@
-#include "gbos.h"
+#include "netlib.h"
/* necho: send a SLIP-framed packet over the link port and print the reply.
Talks to a host gateway (tools/gateway.py) that echoes frames back. */
-#define SLIP_END 0xC0
-#define SLIP_ESC 0xDB
-#define SLIP_ESC_END 0xDC
-#define SLIP_ESC_ESC 0xDD
-
-static void slip_send(const char *buf, unsigned char len) {
- unsigned char i, c;
- ssend(SLIP_END);
- for (i = 0; i < len; i++) {
- c = (unsigned char)buf[i];
- if (c == SLIP_END) { ssend(SLIP_ESC); ssend(SLIP_ESC_END); }
- else if (c == SLIP_ESC) { ssend(SLIP_ESC); ssend(SLIP_ESC_ESC); }
- else ssend(c);
- }
- ssend(SLIP_END);
-}
-
-static unsigned char slip_recv(char *buf, unsigned char max) {
- unsigned char len = 0, c;
- for (;;) {
- c = srecv();
- if (c == SLIP_END) { if (len) return len; continue; }
- if (c == SLIP_ESC) {
- c = srecv();
- if (c == SLIP_ESC_END) c = SLIP_END;
- else if (c == SLIP_ESC_ESC) c = SLIP_ESC;
- }
- if (len < max) buf[len++] = (char)c;
- }
-}
-
void main(void) {
char buf[64];
unsigned char len;