summaryrefslogtreecommitdiff
path: root/src/wasp-bus-binary.el
diff options
context:
space:
mode:
authorLLLL Colonq <llll@colonq>2026-04-26 23:47:18 -0400
committerLLLL Colonq <llll@colonq>2026-04-26 23:47:18 -0400
commit75e005e81b73d8471f16dc5fad7bbdc312bdbfe7 (patch)
tree1ad7d61b04c44fc52b453aef44868a42012f3551 /src/wasp-bus-binary.el
parentcf266a56f30daae8b9af7c9bc3267c61b1973192 (diff)
Diffstat (limited to 'src/wasp-bus-binary.el')
-rw-r--r--src/wasp-bus-binary.el20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/wasp-bus-binary.el b/src/wasp-bus-binary.el
index ae4ae0e8..5b612e7b 100644
--- a/src/wasp-bus-binary.el
+++ b/src/wasp-bus-binary.el
@@ -95,11 +95,15 @@ Return non-nil if a message was successfully parsed."
(logand (lsh x -16) #xff)
(logand (lsh x -24) #xff)))
+(defvar w/bus-binary-bad-string nil)
(defun w/bus-binary-build-length-prefixed (s)
"Turn S into a length-prefixed unibyte string."
- (s-concat
- (w/bus-binary-build-int32le (string-bytes s))
- s))
+ (let* ( (bs (string-bytes s))
+ (ret (s-concat (w/bus-binary-build-int32le bs) (encode-coding-string s 'utf-8))))
+ (unless (= (+ bs 4) (string-bytes ret))
+ (setf w/bus-binary-bad-string s)
+ (error "Bad length when adding length prefix!"))
+ ret))
(defun w/bus-binary-convert-event (ev)
"Convert the s-expression EV to a string event."
@@ -138,11 +142,11 @@ Return non-nil if a message was successfully parsed."
(set-buffer-multibyte nil)
(erase-buffer))
(make-network-process
- :coding 'no-conversion
- :name w/bus-binary-process
- :buffer nil
- :host w/bus-binary-host
- :service w/bus-binary-port
+ :coding 'no-conversion
+ :name w/bus-binary-process
+ :buffer nil
+ :host w/bus-binary-host
+ :service w/bus-binary-port
:filter #'w/bus-binary-process-filter)
(w/binary-sub-all))