diff --git a/artiq/coredevice/comm_generic.py b/artiq/coredevice/comm_generic.py index 8a8277ac1..1d42a12c1 100644 --- a/artiq/coredevice/comm_generic.py +++ b/artiq/coredevice/comm_generic.py @@ -166,7 +166,7 @@ class CommGeneric: return self._read_chunk(self._read_int32()) def _read_string(self): - return self._read_bytes()[:-1].decode("utf-8") + return self._read_bytes().decode("utf-8") # # Writer interface @@ -214,7 +214,7 @@ class CommGeneric: self._write_buffer.append(value) def _write_string(self, value): - self._write_bytes(value.encode("utf-8") + b"\0") + self._write_bytes(value.encode("utf-8")) # # Exported APIs diff --git a/artiq/runtime.rs/src/proto.rs b/artiq/runtime.rs/src/proto.rs index 87746e494..e3b40c3c1 100644 --- a/artiq/runtime.rs/src/proto.rs +++ b/artiq/runtime.rs/src/proto.rs @@ -66,14 +66,10 @@ pub fn write_bytes(writer: &mut Write, value: &[u8]) -> io::Result<()> { } pub fn read_string(reader: &mut Read) -> io::Result { - let mut bytes = try!(read_bytes(reader)); - let len = bytes.len() - 1; // length without trailing \0 - bytes.resize(len, 0); // FIXME: don't send \0 in the first place + let bytes = try!(read_bytes(reader)); String::from_utf8(bytes).map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e)) } pub fn write_string(writer: &mut Write, value: &str) -> io::Result<()> { - try!(write_u32(writer, (value.len() + 1) as u32)); - try!(writer.write_all(value.as_bytes())); - write_u8(writer, 0) + write_bytes(writer, value.as_bytes()) }