diff options
author | Yves Fischer <yvesf-git@xapek.org> | 2012-03-05 23:03:24 +0100 |
---|---|---|
committer | Yves Fischer <yvesf-git@xapek.org> | 2012-03-05 23:03:24 +0100 |
commit | 2441e9b57675ef0398cc507318e37cb67d6271cf (patch) | |
tree | cdd3027e1955a0d8762c1b1a99f9a1fc4fb94ce2 | |
parent | c6753ed8974da8090037a52d65415143ebf1c015 (diff) | |
download | ebus-alt-2441e9b57675ef0398cc507318e37cb67d6271cf.tar.gz ebus-alt-2441e9b57675ef0398cc507318e37cb67d6271cf.zip |
ebus-rackets: cleanups
* inserter: unused racket/pretty
* inserter: read-ebus-loop7
* layer2: simplified
-rwxr-xr-x | ebus-racket/inserter.rkt | 18 | ||||
-rw-r--r-- | ebus-racket/layer2.rkt | 5 |
2 files changed, 12 insertions, 11 deletions
diff --git a/ebus-racket/inserter.rkt b/ebus-racket/inserter.rkt index a2ee1a0..bd23e04 100755 --- a/ebus-racket/inserter.rkt +++ b/ebus-racket/inserter.rkt @@ -2,7 +2,6 @@ #lang racket/base (require racket/cmdline racket/tcp - racket/pretty racket/match "db.rkt" "layer7.rkt" @@ -22,12 +21,15 @@ (log-message logger 'info (format "Field: ~a" field) #t) (when (insert?) (apply db-insert-field field)))) - -(define (read-ebus-loop7 input-port) - (let ([fields (layer7-read-ebus (current-input-port))]) - (when (not (or (void? fields) (eof-object? fields))) - (handle-fields fields)) - (cond ((not (eof-object? fields)) (read-ebus-loop7 input-port))))) + +(define (make-ebus-loop7 input-port) + (lambda () + (let loop () + (let ([fields (layer7-read-ebus (current-input-port))]) + (when (not (or (void? fields) (eof-object? fields))) + (handle-fields fields)) + (when (not (eof-object? fields)) + (loop)))))) ;; Start Thread that observe all given log-receivers (define (start-logger-thread receiver1 . receiverN) @@ -88,7 +90,7 @@ (current-input-port cin))) ;; Process Ebus Packets - (read-ebus-loop7 (current-input-port)) + ((make-ebus-loop7 (current-input-port)) ) ) (exit (main)) diff --git a/ebus-racket/layer2.rkt b/ebus-racket/layer2.rkt index 9ed2118..3dd881c 100644 --- a/ebus-racket/layer2.rkt +++ b/ebus-racket/layer2.rkt @@ -55,8 +55,6 @@ synSlave <- ebus-const-syn ;; SYN des Senders (return (ebus-body-masterslave crc payloadSlaveLength payloadSlave crcSlave))))) -(define parse-ebus-master-or-slave (token (choice parse-ebus-mastermaster parse-ebus-masterslave))) - (define parse-ebus-paket (token (seq source <- any-byte destination <- any-byte @@ -65,7 +63,8 @@ payloadLength <- any-byte payload <- (repeat ebus-payload payloadLength payloadLength) body <- (cond ((= destination ebus-const-broadcastaddr) parse-ebus-broadcast) - (else parse-ebus-master-or-slave)) + (else (choice parse-ebus-mastermaster + parse-ebus-masterslave))) (return (ebus-paket source destination primaryCommand |