RS232

I am trying to control a projector using the RS232 connection from a MacBook Pro with a USB to a 9 Pin null modem serial cable. It works well using other equipment, so I know the hardware is working.

Im not interested in using any other method (like front panel buttons on the projector, infrared or Crestron control systems)


All I need to do is power on the projector, switch to the correct input and make 3 simple adjustments. I have the control codes from the projector manufacturer but I don't know what to do with them.


From searching on line there is plenty of reports saying this will work using the Terminal application to type in commands but there is no practical information on how to do this.

Where can get that information? thanks

Posted on Jul 14, 2018 8:35 AM

Reply
Question marked as Top-ranking reply

Posted on Aug 27, 2018 12:24 PM

rccharles wrote:


Figuring what if any data is flowing on the line would be handy.


-- The "blue" box was a simple device that had an led for each line. The light blinked so you knew something was happening.

-- A big step up was a data analysis device. Fit in a brief case.

-- Oscilloscope. Could check on line at a time.

-- You could hock it up to another mac with a serial port to get you technique down.


At the low-end of troubleshooting, a breakout box can be sufficient. This is likely what rccharles is referring to as a "blue" box. (Blue boxes in other contexts are completely different.) The breakout box doesn't show the characters traversing the box, but it does show signal activity. Almost as cheap as the breakout box and useful in conjunction with same is a t-cable. Some manual wiring work required, there. Digital monitors and commercial serial taps are also available, and tend to be a little more expensive. In this case, sending printable text to some other device temporarily swapped in for the projector will likely suffice.


There are very low-level examples of using C to directly read and write to a serial device available, as well as higher-level examples using Python. Here's a tweaked version of the Python (Python3) PySerial from that previous example, though I don't have a projector configuration nor this USB-to-serial dongle to test this code with.

ser = serial.Serial('/dev/tty.UC-232AC', 9600, timeout=0.5)

ser.write(b"\xBE\xEF\x03\x06\x00\x2A\xD3\x01\x00\x00\x60\x00\x00")

time.sleep(0.1)

ser.close()


I'd start with the printf command from earlier, assuming the serial port is at 9600 and reasonable defaults. Issue that command directly.

printf '\x0BE\x0EF\x003\x006\x000\x02A\x0D3\x001\x000\x000\x060\x000\x001' > /dev/tty.UC-232AC


To make that into a program for later use (assuming it works), the following is a two-line shell script:

#!/bin/bash

printf '\x0BE\x0EF\x003\x006\x000\x02A\x0D3\x001\x000\x000\x060\x000\x001' > /dev/tty.UC-232AC


The following is also two lines. The #! stuff, then a long line starting with the stty command to force the baud rate. and this if the baud rate for the USB-to-serial adapter device doesn't match what the projector expects.

#!/bin/bash

stty -f /dev/tty.UC-232AC 9600 | printf '\x0BE\x0EF\x003\x006\x000\x02A\x0D3\x001\x000\x000\x060\x000\x001' > /dev/tty.UC-232AC


Also see:

https://electronics.stackexchange.com/questions/5167/set-rs232-port-options-from -macos-x-cli


Given there've been bash commands and other code previously posted, so the next best alternative available here is likely to pay somebody to write a GUI tool for you.

36 replies
Question marked as Top-ranking reply

Aug 27, 2018 12:24 PM in response to rccharles

rccharles wrote:


Figuring what if any data is flowing on the line would be handy.


-- The "blue" box was a simple device that had an led for each line. The light blinked so you knew something was happening.

-- A big step up was a data analysis device. Fit in a brief case.

-- Oscilloscope. Could check on line at a time.

-- You could hock it up to another mac with a serial port to get you technique down.


At the low-end of troubleshooting, a breakout box can be sufficient. This is likely what rccharles is referring to as a "blue" box. (Blue boxes in other contexts are completely different.) The breakout box doesn't show the characters traversing the box, but it does show signal activity. Almost as cheap as the breakout box and useful in conjunction with same is a t-cable. Some manual wiring work required, there. Digital monitors and commercial serial taps are also available, and tend to be a little more expensive. In this case, sending printable text to some other device temporarily swapped in for the projector will likely suffice.


There are very low-level examples of using C to directly read and write to a serial device available, as well as higher-level examples using Python. Here's a tweaked version of the Python (Python3) PySerial from that previous example, though I don't have a projector configuration nor this USB-to-serial dongle to test this code with.

ser = serial.Serial('/dev/tty.UC-232AC', 9600, timeout=0.5)

ser.write(b"\xBE\xEF\x03\x06\x00\x2A\xD3\x01\x00\x00\x60\x00\x00")

time.sleep(0.1)

ser.close()


I'd start with the printf command from earlier, assuming the serial port is at 9600 and reasonable defaults. Issue that command directly.

printf '\x0BE\x0EF\x003\x006\x000\x02A\x0D3\x001\x000\x000\x060\x000\x001' > /dev/tty.UC-232AC


To make that into a program for later use (assuming it works), the following is a two-line shell script:

#!/bin/bash

printf '\x0BE\x0EF\x003\x006\x000\x02A\x0D3\x001\x000\x000\x060\x000\x001' > /dev/tty.UC-232AC


The following is also two lines. The #! stuff, then a long line starting with the stty command to force the baud rate. and this if the baud rate for the USB-to-serial adapter device doesn't match what the projector expects.

#!/bin/bash

stty -f /dev/tty.UC-232AC 9600 | printf '\x0BE\x0EF\x003\x006\x000\x02A\x0D3\x001\x000\x000\x060\x000\x001' > /dev/tty.UC-232AC


Also see:

https://electronics.stackexchange.com/questions/5167/set-rs232-port-options-from -macos-x-cli


Given there've been bash commands and other code previously posted, so the next best alternative available here is likely to pay somebody to write a GUI tool for you.

Jul 14, 2018 4:47 PM in response to beyik_lmd

It's not clear if the hardware works elsewhere, or if the hardware works on this system.


Okay, so the USB to serial adapter may require a driver. Two of the more common choices are adapters using an FTDI chipset, and others using the Prolific PL-2303 as that's very common and widely available, and drivers are either available as an add-on or are built-in. You'll need to sort out which you have. Both Prolific and FTDI have drivers available for macOS.


I've had some success with the Plugable USB-to-serial product.


Once you know the device and the driver involved, you'll then find that the USB device will present itself as a device under /dev somewhere. That's either in the driver documentation, or you'll have to rummage the /dev directory around the USB device connection and see what device(s) appear in /dev when the USB device is connected.


The specific device name used on your system will vary based on the particular USB-to-serial driver installed here, and by the number of USB-to-serial devices in use if there's more than one.


Now it's that device name that you'll need to "open" and access. You'll want to read or far more likely here write to the device. That'll then send the characters up the serial line to the target device. In C, you can open the device with an fopen call or similar, and use fwrite and fread or ilk, and start tossing write and read operations at the remote end. Python, bash, swift and most other languages are similar here.


Here's an example of using bash with a serial device that's known on that system as /dev/tty.usbmodem1431 on that system: macos - Write to MAC's serial port to talk to Arduino (fopen( /dev/tty.usbmodem1431) hangs forver) - Stack Overflow


It's possible to use the bash echo or printf command-line commands to send text and also send escape and control sequences, if that's what the specific device requires. For one example, Escape sequences with "echo -e" in different shells - Unix & Linux Stack Exchange


Apple also has available some more detailed documentation on using Objective C with serial devices, and other folks have examples of using Swift with USB serial devices.


Here's a discussion of Python and the associated pyserial package for something similar, though I've not used that path: https://stackoverflow.com/questions/21839451/serial-ctrla-escape-sequence#218402 71


If you're interested in learning more about shell scripting, there's a (apparently now archived) shell scripting primer available from Apple.


It is possible to wrap the bash shell commands into a shell script and wrap that in an automator action, which means that you could give the tool you're working on a graphical user interface front-end; a tool that allows you to control the projector without going to the command line.


If you're curious about just what terminals and serial communications can be used for, everything you could possibly want to know about escape and control sequences and serial terminals is available in the documentation that's posted at VT100.net.


The screen command mentioned earlier can be used here, but that's fairly complex. It's probably overkill for this usage. The screen command can also be cryptic, even if you're familiar with it. The ** (copy Unix) command is probably a better choice to access and manually send along the characters directly. Rather than screen or **, it's also possible to use some of the available add-on terminal emulators to directly access the device. zterm was one that could do that. This if you're not going to script this more directly using bash and a stty command to set the terminal speed, and to then use an echo or printf command to send the necessary characters. Or a C or Objective C or Swift or Python or other script for this.

Jul 18, 2018 1:25 PM in response to beyik_lmd

beyik_lmd wrote:


Thanks for replying MrH


The problem is I have no understanding at all of how to send these commands to the projector. Unfortunately I did not understand any of your suggestions.


You're looking for a program. One or maybe two short programs to start with, and probably eventually one that's a little more complex. One program that sends "on" and one that sends "off", for instance. A little further along, a program that can send both, and that can show the selection and the setting to the GUI.


The stuff you're looking at in that documentation? These are characters.


You are entering characters into the text boxes here in the ASC forum. Same thing. Instead of sending the characters into the text box here, you can send different characters into a different "box"; into the device that's associated with the USB widget, and that's then wired to the projector. That is, you write characters to the device. The tools available here can vary.


In this case, you're sending the equivalent of the following characters:


BE EF 03 06 00 2A D3 01 00 00 60 00 00


BE EF 03 06 00 2A D3 01 00 00 60 00 01


Now these particular printable characters are representing characters that are not printable characters, so you'll end up writing these as the base 16 values shown. In what's called hexadecimal. You're already using some characters that aren't printable, such as the character that gets used when you press return in the text boxes here in the ASC forums. There are others.


The following is in Terminal.app and the command line...


Here's the bash printf command that sends these base 16 values; the use of the three digits for each and the \x are part of the printf command syntax that tells the printf command that the values following are using base 16. The quote character is a single vertical apostrophe character. Some text editors and some tools on macOS may substitute different quoting characters, and those won't work here.


printf '\x0BE\x0EF\x003\x006\x000\x02A\x0D3\x001\x000\x000\x060\x000\x000'

printf '\x0BE\x0EF\x003\x006\x000\x02A\x0D3\x001\x000\x000\x060\x000\x001'


As a completely harmless text of this, you can sound the bell at the command line:


printf '\x007'


That 07 is the base 16 encoded version of the bell character. Yes, there's a bell character in the character set. It's another of the non-printable characters. If you enter that printf command with that specified string and you hear a beep, then it's working. If you don't hear a beep, there's a problem.


With the addition of the USB device name (shown below as /dev/tty.UC-232AC as that's what you've found, but that device name with vary by the specific device for other folks), then the bash shell commands will look something like the following printf commands. The following should work, but I don't have the necessary serial device to test the syntax with.


printf '\x0BE\x0EF\x003\x006\x000\x02A\x0D3\x001\x000\x000\x060\x000\x001' > /dev/tty.UC-232AC


printf '\x0BE\x0EF\x003\x006\x000\x02A\x0D3\x001\x000\x000\x060\x000\x001' > /dev/tty.UC-232AC


You've already located the device name /dev.tty.UC-232AC. For other folks using different USB adapters? Look at the USB adapter documentation for the device name that it'll present to macOS, or use a command such as sudo ls /dev issued before and again after the device is connected, and look at which device is added when the USB adapter is connected. The sudo will require an administrative password, but is otherwise harmless. The device name will be in a format similar to /dev/tty.whatever, but probably with the USB adapter name embedded.


Or you can convince somebody to enter the echo or printf command into a shell script for you, or similar. Writing a small GUI-based program to control the projector should be a fairly quick project for someone familiar with Objective C or Swift on macOS, or the use of Automator.app with calls to bash shell scripts. Access to the projector would be very handy for debugging the program.


A little more work for the programmer would be sending a query to the projector, asking its status. The projector will then send back the specified string, and the program can then be modified to decide whether there's a projector on the far end and whether it's powered up or powered down.


If this projector is being used at a school for instance, and if Macs are in use at the school, ask one of the local kids. This would the sort of project that some of them might be interested in working on.

Jul 14, 2018 3:58 PM in response to beyik_lmd

Well, we should be able to figure this out eventually



the adapter folks say you should install the drivers from here:


drivers from http://www.aten.com/au/en/products/usb-&-thunderbolt/usb-converters/uc232a/#.W0p 7_YZV3NR


the mention of cat...

I assume the data is in hex and needs to be converted to binary.


echo -n "beef0306002ad3010000600000" | xxd -r -p | cat >/dev/"21, 5 14 Jul 19:36 **.UC-232AC"



| xxd -r -p converts to binary. leave out if you do not need.


This says you should use the screen command. It will set the baud rate.

https://davidvielmetter.com/tricks/serial-commuications-on-a-macbook-pro/

did you try the screen command as seen in the above link?

Did you install the drivers?

Jul 14, 2018 11:38 AM in response to beyik_lmd

What is the name and model of the projector?


What is the name and model of the adapter


Could you provide a link to some of the web pages you found?


I remember the day ....

https://davidvielmetter.com/tricks/serial-commuications-on-a-macbook-pro/


First problem ... finding the name of the rs232 device.


this is the best I can do for figuring out the device name.

detach the usb adapter.

ls -l /dev

attach the adapter

ls -l /dev


see what changed. I assume the device starts with tty


You may need to change the permissions on the device.


R

Jul 26, 2018 2:32 PM in response to beyik_lmd

Have you seen this manual?

http://www.hitachi-america.us/supportingdocs/forhome/DisplayTechnologiesGroup/lc dprojectors/SupportingDocuments/11_techn…

see page 16. You need to configure the communications port and the settings need to match what your comm app has set up ( coolterm ).



RUser uploaded file

PS. obviously written by a hardware type, because there hardware documentation is excellent.

Jul 18, 2018 10:24 AM in response to beyik_lmd

Well, the windows programmer who knows something about the DOS prompt should be able to help. A computer is a computer.


Let's try a slightly different track. This app might do the trick.

Serial - Modern Terminal for the Mac - Decisive Tactics, Inc.


It's a seven day trial, but they say 30 on their web site.


I had an old adapter to my long gone GM Corsica. [ good for reinforcing pack rate tendencies. ] I attached it to my mini. Got some interesting stuff.


crank up serial. serial > terminal > settings...

User uploaded file

solved several mysteries.

User uploaded file

What I think you do next is send string. serial > terminal > send string...


While your at it, I'd start the log. I don't think it can hurt.


User uploaded file


Notice how I started the string with 0x. I got the string from the table you provided.


R

Jul 27, 2018 11:12 AM in response to beyik_lmd

I should have started with step #2. I left out the earlier step. You need to adjust the baud rate first.


I didn't mean for you to enter hex aabbaabb. Since I do no have a serial device to use, my sending of data will not work.


You should pick one of the hex strings from the manual. Try to pick something that will do something obvious. Power off? Although I would not want to do too many of them.


User uploaded file


R

Sep 15, 2018 1:22 PM in response to beyik_lmd

RS-232 has been around for a long time. The manufacture of your projector had a lot of documentation, but wasn't end-to-end. I've seen a lot of that in my day.


Your going to have to find someone to assist you. A retired person who wants to figure this out.


I think you need at a minimum, a break out box to see if there is any activity on the lines.


Here is the breakout box, my "blue box", that I remember:


User uploaded file


This is for a 25 pin connector which is called a db25 connector. You need to count the number of pins on your connector.


You then need to find a breakout box that supports your pins. I used the box at slower speeds than 19.2k. Don't know how effective it would be at higher speeds.


db9, 9 pins tester

Amazon.com: CableMax RS-232 LED link Tester DB-9 Male to DB-9 Female: Computers & Accessories


User uploaded file


This will show you the pins, but it's not possible to jumper pins together.


In order to jumper the pins, you need something like this.

Amazon.com: DB9 Breakout Connector RS232 Serial 9 Pin Connector Db9 Terminal (Male x 1, Female x 1): Home Audio & Theate…


User uploaded file

This would be extreme diy, since you would have to wire all the pins just you you could jumper what you need.

fyi: https://www.arcelect.com/rs232.htm


R

Jul 14, 2018 2:29 PM in response to rccharles

Thanks for replying, greatly appreciated.


I have a Hitachi CP-X 2510 here that I can use to perform tests with, I have the full list of Hitachi control codes for it, this is an example of just two of them:

User uploaded file


The USB to Serial adapter is an ATEN UC232A

this is ATENS website info: ATEN UC232A

Its identified in Terminal as: 21, 5 14 Jul 19:36 **.UC-232AC


This is one example of a web search which has zero useful information for me:

"As programs go it would be very easy. In UNIX (Mac OS X is Unix) all devices look and act like files, so all you have to do is "print" the device that connects to the RS-232 connector. You can test out the commands by simply sending commands from the terminal without any programming. Just use the "cat" command."

Jul 18, 2018 10:30 AM in response to rccharles

There is a snafu with ASC today. It normal. It's only allowing three images to be posted correctly. I'll continue here.


Notice how I started the string with 0x. I got the string from the table you provided.

beef0306002ad3010000600000


User uploaded file


You can see some activity on the main serial window.


From a perspective, this is a hardware terminal emulator. You are sitting at a dumb, dumb terminal like some of us did in the '70s & '80s.


R

Jul 26, 2018 10:55 AM in response to MrHoffman

Thanks rc and MrH, I have tried quite a few things but the only two things I have been able to do is:


1 - connect the USB to Serial adapter to an AMX control system to prove that the serial adapter works. Using AMX software I can control any audiovisual device with RS232 ports: eg sound amplifier, projector, switcher, mixer. Therefore the USB to Serial adapter is working perfectly for the AMX system.


2 - use Terminal to find the tty info of the USB to Serial adapter I have connected

the result is: 1 26 Jul 15:59 **.UC-232AC


printf '\x007' If you enter that printf command with that specified string and you hear a beep, then it's working. If you don't hear a beep, there's a problem.

I did not hear a beep, sound is working correctly in other apps


3 - Tried Coolterm for 5 days and got no results



What Id like to do is use the information I obtained from Hitachi about the specific Hitachi projector I have connected to my Mac just now.


Power Set Turn off BE EF 03 06 00 2A D3 01 00 00 60 00 00

Turn on BE EF 03 06 00 BA D2 01 00 00 60 01 00

Input Source Set RGB IN 1 BE EF 03 06 00 FE D2 01 00 00 20 00 00



How can I use that data from Hitachi in either Terminal or Cool Term to control the projector?


Many thanks again

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

RS232

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.