From f7f2f4a611f15d98d8e33241dc65d5cbfe7ff03b Mon Sep 17 00:00:00 2001 From: Ebus-at-dockstar Date: Sun, 27 Jul 2014 17:36:09 +0200 Subject: improve logging, close input ports after usage --- ebus-racket/ebus/layer7.rkt | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'ebus-racket/ebus') diff --git a/ebus-racket/ebus/layer7.rkt b/ebus-racket/ebus/layer7.rkt index 76ea6ae..b3caf0b 100644 --- a/ebus-racket/ebus/layer7.rkt +++ b/ebus-racket/ebus/layer7.rkt @@ -9,9 +9,12 @@ (define-logger ebus7) (define definition - (parameterize ([collapse-whitespace #t] - [xexpr-drop-empty-attributes #t]) - (xml->xexpr (document-element (read-xml (open-input-file "../ebus-xml/ebus.xml")))))) + (let* ([in (open-input-file "../ebus-xml/ebus.xml")] + [xexpr (parameterize ([collapse-whitespace #t] + [xexpr-drop-empty-attributes #t]) + (xml->xexpr (document-element (read-xml in))))]) + (close-input-port in) + xexpr)) (define (paket ebus-paket) (define primaryCommand (number->string (layer2-ebus-paket-primaryCommand ebus-paket))) @@ -70,13 +73,13 @@ (list 'data1c (lambda (name field offset payload) (list name 'data1b (field-decoder-data1c (list-ref payload offset))))) (list 'byte (lambda (name field offset payload) - (list name 'byte offset (list-ref payload offset)))) + (list name 'byte (list-ref payload offset)))) (list 'data2b (lambda (name field offset payload) (list name 'data2b (field-decoder-data2b (list-ref payload offset) (list-ref payload (+ offset 1)))))) (list 'data2c (lambda (name field offset payload) - (list name 'data2c offset + (list name 'data2c (field-decoder-data2c (list-ref payload offset) (list-ref payload (+ offset 1)))))) (list 'word (lambda (name field offset payload) (list name 'word (field-decoder-word (list-ref payload offset) (list-ref payload (+ offset 1)))))) -- cgit v1.2.1