Many thanks to @jcaron and @robert-hh, it now works. I found I had to specify the terminator as a byte string (a variation I had tried before but always got a type error, as robert-hh noted), but I had never tried making the command string a bytes field as well, in fact I didn't know that was possible. If I'm totally honest I was only vaguely aware that there is a difference between byte strings and strings. I had to Google it, and I'm still not sure I entirely get it, but moot point right now.
Anyway, thanks again.
;-)