DMcK
Posts: 20
Joined: Sun Jul 01, 2012 4:51 am

Can't get serial (MAX3232 chip) port to work

Thu Feb 14, 2013 4:46 pm

Hi,
I've constructed an RS-232 cable using http://www.trainelectronics.com/RaspberryPi/ and am having trouble getting to work. I'm trying to control my TV by sending sending simple codes over the serial port.

Code: Select all

[email protected]:~$ echo -en "\x02*pof\x03" > /dev/ttyAMA0
-bash: /dev/ttyAMA0: Permission denied
or
[email protected]:~$  echo "^B**pof^C" > /dev/ttyAMA0
-bash: /dev/ttyAMA0: Permission denied
Permission is also denied if I use "sudo". Issuing the commands using "sudo su" gives no errors, but doesn't turn the TV off or on.

My cmdline.txt has no reference to AMA0:

Code: Select all

dwc_otg.lpm_enable=0 root=/dev/sda1 rootfstype=ext4 noatime quiet rootwait loglevel=1 zram.num_devices=2
Also, /etc/inittab has no reference to AMA0. I'm using raspbmc; I guess the creators had already changed those.

I've tested the codes and TV using Windows and can successfully turn the TV off/on etc. so I know that is working. I've tried swapping the Tx/RX leads on the GPIO but that doesn't work either.

Am I missing something really obvious or does anyone have any suggestions?

Thanks!

larsth
Posts: 54
Joined: Sat Aug 27, 2011 9:51 pm
Contact: Website

Re: Can't get serial (MAX3232 chip) port to work

Thu Feb 14, 2013 8:19 pm

Edit:
Sorry.
I was too quick, and did not read this line:
"I've tested the codes and TV using Windows and can successfully turn the TV off/on etc. so I know that is working. "
----
First things first.

Before software and code - make sure the hardware works.

That is:
  • No cold solderings.
  • The chip is supplied with the correct voltage.
  • Check the output in both directions using a voltmeter.
  • Look in the datasheet for the chip to see what should came out.
  • Also the Tx signal from one end should go the Rx signal of the other end, and:
  • the Rx signal from one end should go the Tx signal of the other end.
  • gnd from one end should be connected to gnd of the other end.
Image
from http://airborn.com.au/serial/rs232.html

Hope that helps a bit.

/Lars

Note: I am not a native speaker of English, so incorrect use of the English language occurs.

DMcK
Posts: 20
Joined: Sun Jul 01, 2012 4:51 am

Re: Can't get serial (MAX3232 chip) port to work

Thu Feb 14, 2013 8:52 pm

Thanks for the reply, Lars.
I dug up an old PC with a serial port and connected the RPi to it using my cable. I started up Putty and was able to establish a serial connection to the RPi and log in. So the hardware is all working as desired.

A bit of googling also showed me how to set up permissions to the serial port:

Code: Select all

chown pi /dev/ttyAMA0
chmod a+rw /dev/ttyAMA0
[email protected]:/home/pi# ls -l /dev/ttyAMA0
crw-rw-rw- 1 pi tty 204, 64 Feb 14 13:36 /dev/ttyAMA0
So now I have permissions and the hardware workds... Unfortunately, I still can't get the codes to work. I'm not sure if it's an ASCII/hex thing or if it's something else.

gazzat5
Posts: 12
Joined: Thu Jun 14, 2012 4:51 pm

Re: Can't get serial (MAX3232 chip) port to work

Tue Jun 25, 2013 11:38 am

Sorry for dredging up an old topic, but
raspbmc runs a service to maintain a serial console on the gpio serial pins.
if you run the following cmd you'll see what i mean:

Code: Select all

ps aux | grep ttyAMA0
and the following source code shows where:
https://bitbucket.org/durin42/raspbmc-m ... yAMA0.conf

it's in /etc/init/ttyAMA0.conf

you'll either have to disable it (edit the file as root and change the start on to
start on []

Code: Select all

nano /etc/init/ttyAMA0.conf
or move the file (as root)

Code: Select all

mv /etc/init/ttyAMA0.conf /home/pi
then reboot and ala-kazaaam access the port with minicom, screen, whatever man!

gevard
Posts: 1
Joined: Wed Nov 04, 2015 12:49 pm

Re: Can't get serial (MAX3232 chip) port to work

Wed Nov 04, 2015 1:00 pm

Hello

I have installed a recent version of respbian (uname -a : Linux raspberrypi 4.1.7-v7+ #817 SMP PREEMPT Sat Sep 19 15:32:00 BST 2015 armv7l GNU/Linux) and I have similar problem with my ttyAMA0 port.

I don't get any /etc/init/ttyAMA0.conf file.

At boot the port cannot be open due to permission issue.

It's OK after typing:
chown pi /dev/ttyAMA0
chmod a+rw /dev/ttyAMA0


Problem is that at next rebbot I have to issue each time the same command.
Any help is welcome.

Return to “Troubleshooting”