4

I'm on Mac OS X 10.6, and I've been using the screen command to send ASCII data over a serial port. However, not all the data I would like to send is pure ASCII, and I would like to be able to send raw bytes over the serial port.

Is this possible? Does anyone know of any programs that can do this?

MPelletier
  • 16,256
  • 15
  • 86
  • 137
Zach Rattner
  • 20,745
  • 9
  • 59
  • 82
  • What exactly is the source of the data you want to write? What kind of program are you using this in? – vbence Mar 26 '11 at 23:43
  • I'm testing a Bluetooth modem, and I'd like to send 0x0a to it. At this point, it doesn't really matter what the source is (text file, keyboard, etc.) – Zach Rattner Mar 26 '11 at 23:47

3 Answers3

4

The best option is to use CoolTerm. It is simple to use and there is an option that let you send just byte(s) of data (instead of ASCII characters).

I use this option all the time to emulate a micro-controller with my computer when I deal with a serial interface.

When CoolTerm is installed go under: Connection-> "Send String..." It will open a window, choose HEX (instead of ASCII). If you need to send 0xAA for example, just write AA in the window and press send (after making the serial connection).

Hope that helps.

Mickael T
  • 895
  • 2
  • 8
  • 19
4

If you want to send the data from a shellscript try:

cp datafile /dev/cu.serial
vbence
  • 20,084
  • 9
  • 69
  • 118
  • Neither tty nor cu are showing up on the other side with this approach. – Zach Rattner Mar 26 '11 at 23:46
  • But do you have a `/dev/something` for your device? – vbence Mar 27 '11 at 00:04
  • Yes, and I was able to get your suggestion working. However, the values are still being sent as ASCII. For example, my "datafile" contained two characters: 12. When I cp'd the file, I read 3132 on the other end (0x31 is the ASCII code for 1 and 0x32 is 2). – Zach Rattner Mar 27 '11 at 00:12
  • I downloaded a hex editor (http://ridiculousfish.com/hexfiend/) and was able to enter my raw binary in there. It works perfectly now. Thanks! – Zach Rattner Mar 27 '11 at 00:23
  • How do you control the speed of transfer (ie. baud rate)? – scipilot Sep 26 '21 at 04:08
  • @scipilot you can do that with the setserial command – vbence Sep 27 '21 at 09:05
  • @scipilot correction: on mac you can use stty with some caveats. see: https://stackoverflow.com/questions/5539192/how-to-set-the-baud-rate-for-macs-in-a-terminal – vbence Nov 02 '21 at 08:53
1

MuTerm2 is cross-platform (Java/PureJavaComm) and presumably works on MacOS (not tested): https://github.com/edartuz/muterm2

user2053898
  • 479
  • 1
  • 5
  • 8