summaryrefslogtreecommitdiff
path: root/ebus-racket
diff options
context:
space:
mode:
authorYves Fischer <yvesf-git@xapek.org>2012-02-26 02:15:43 +0100
committerYves Fischer <yvesf-git@xapek.org>2012-02-26 02:15:43 +0100
commitb71ecd26a9a0822a890f9aa494c6821356ef6bea (patch)
treeee158f301ebc3c07bcda785f35377a1fd72c8a13 /ebus-racket
parent99e5d85621eb3b7153da9c7c46c3ab39f5d99f1f (diff)
downloadebus-alt-b71ecd26a9a0822a890f9aa494c6821356ef6bea.tar.gz
ebus-alt-b71ecd26a9a0822a890f9aa494c6821356ef6bea.zip
ebus-racket: cli interface
Diffstat (limited to 'ebus-racket')
-rw-r--r--ebus-racket/.gitignore1
-rwxr-xr-xebus-racket/dumper.rkt27
-rw-r--r--ebus-racket/parser.rkt (renamed from ebus-racket/parse.rkt)24
3 files changed, 34 insertions, 18 deletions
diff --git a/ebus-racket/.gitignore b/ebus-racket/.gitignore
new file mode 100644
index 0000000..724bbe1
--- /dev/null
+++ b/ebus-racket/.gitignore
@@ -0,0 +1 @@
+compiled/
diff --git a/ebus-racket/dumper.rkt b/ebus-racket/dumper.rkt
new file mode 100755
index 0000000..7ac1da6
--- /dev/null
+++ b/ebus-racket/dumper.rkt
@@ -0,0 +1,27 @@
+#! /usr/bin/env racket
+#lang racket
+
+(require "parser.ss")
+
+;(define verbose? (make-parameter #f))
+(define connect-host? (make-parameter null))
+(define connect-port? (make-parameter null))
+
+(define greeting
+ (command-line
+ #:once-each
+; [("-v") "Verbose mode" (verbose? #t)]
+ [("-c" "--connect") host port
+ "Connect to server <host> <port>"
+ (connect-host? host)
+ (connect-port? (string->number port))
+ ]))
+; Connect
+(if (or (null? (connect-host?)) (null? (connect-port?)))
+ (display "Using stdin")
+ (let-values ([(cin cout) (tcp-connect (connect-host?) (connect-port?))])
+ (display (format "Connected to ~s ~s ~n" (connect-host?) (connect-port?)))
+ (current-input-port cin)))
+
+;
+(read-ebus-loop (current-input-port))
diff --git a/ebus-racket/parse.rkt b/ebus-racket/parser.rkt
index dcc749c..1b9ed5b 100644
--- a/ebus-racket/parse.rkt
+++ b/ebus-racket/parser.rkt
@@ -88,23 +88,11 @@
(read-byte input-port)
;(file-position input-port (+ 1 (file-position input-port)))
(read-ebus input-port)))))
-
-(define (main input-port)
- (let ([paket (read-ebus input-port)])
- (display (format "Paket ~s~n" paket))
- (cond ((not (eof-object? paket)) (main input-port)))))
-
-;(define input-port (open-input-file "../doc/dumps/dump_2011-12-17_23-04-00.bin"))
-(main (current-input-port))
-
-;((make-reader ebus-payload #:sof? #f #:eof? #f) (open-input-bytes (bytes 169 1 3 96)))
-
-
-
-;(define-values (cin cout)
-; (tcp-connect "localhost" 2222))
+(define (read-ebus-loop input-port)
+ (let ([paket (read-ebus (current-input-port))])
+ (display (format "Paket ~s~n" paket))
+ (cond ((not (eof-object? paket)) (read-ebus-loop input-port)))))
-;
-;(define (work-on port)
-; (pretty-print token)
+(provide read-ebus
+ read-ebus-loop) \ No newline at end of file