Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (define (hackrf-start-rx ctx d stream-processor)
- (let ([ctlin (second ctx)]
- [ctlout (third ctx)]
- [r (fourth ctx)])
- (displayln
- (string-append "startrx " d) ctlin)
- (flush-output ctlin)
- (sleep 0.1)
- (let ([line (read-line ctlout)])
- (if (not (equal? line "creating stream"))
- (raise line)
- (let ([dataout (open-input-file
- (string-append "/tmp/hackrfkern-"
- r
- "/dataout-"
- d))])
- (thread
- (lambda ()
- (letrec ([loop (lambda ()
- (if (eof-object? (peek-byte dataout))
- (void)
- (let* ([line (read-line dataout)]
- [tokens (string-split line)])
- (if (or (not (= (length tokens) 3))
- (not (string=? (car tokens) "rx")))
- (raise (string-append "bad prefix in RX stream: " line))
- (stream-processor dataout (string->number (third tokens))))
- (loop))))])
- (loop)))))))))
- (define (sp-to-file path)
- (let* ([out (open-output-file path)]
- [buffer-size 100000]
- [buffer (make-bytes buffer-size)])
- (lambda (in nbytes)
- (if (> nbytes buffer-size)
- (begin
- (set! buffer-size nbytes)
- (set! buffer (make-bytes buffer-size)))
- (void))
- (read-bytes! buffer in 0 nbytes)
- (write-bytes buffer out 0 nbytes))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement