Venturer
Posts: 2
Joined: Fri Jul 27, 2012 7:50 pm

Openning Serial Ports

Thu Aug 02, 2012 5:54 pm

Hi,

I have been going round in ever decreasing circles for the past few days trying to connect to the serial port on the GPIO.

I have installed PySerial and I have tryed to add the pi user to the dialout group with:

sudo usermod -a -G dialout pi

which returns without error.

When I try to connect to '/dev/ttyS0' i get file or directory not found.

I have tried '/dev/ttyAMA0' and get permission denied

1) which is the correct device name to use?

2) How do I get permission to open it?

Thanks,

Steve

timhoffman
Posts: 85
Joined: Sat Nov 05, 2011 11:31 pm

Re: Openning Serial Ports

Fri Aug 03, 2012 1:18 am

Hi

You need to use /dev/ttyAMA0

But this requires you do a few things.

1.Make sure your userid (default is pi) is a member of the dialout group. (which your usermod command did)
2. You need to stop the getty running on the GPIO serial console.

To do this you need
- remove references to /dev/ttyAMA0 from /boot/cmdline.txt - which sets up the serial console on boot.
In my case old contents

Code: Select all

dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 rootwait
and new contents

Code: Select all

dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 rootwait
Also you need to disable the getty on that serial port in /etc/inittab
Comment out the following line

Code: Select all

#2:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100
Oh and reboot ;-)

Cheers

Tim

Venturer
Posts: 2
Joined: Fri Jul 27, 2012 7:50 pm

Re: Openning Serial Ports

Fri Aug 03, 2012 6:51 pm

Tim,

Thank you for that information. I have done the changes and I can now open ttyAMA0 and (apparently) write to it.

The contents of my two files were slightly different. When I have confirmed I am actually send the data (I have to do a bit of hardware first!) I shall post the complete sequence I have done in case it helps someone else.

Steve

rmashrmash
Posts: 1
Joined: Wed Sep 04, 2013 12:16 am

Re: Openning Serial Ports

Sat Mar 08, 2014 7:33 pm

Thanks very much. This worked nicely for me.

User avatar
AndrewS
Posts: 3625
Joined: Sun Apr 22, 2012 4:50 pm
Location: Cambridge, UK
Contact: Website

Re: Openning Serial Ports

Mon Jun 23, 2014 8:40 pm

I wrote a little script to make it easier to disable (and re-enable) the getty https://github.com/lurch/rpi-serial-console

tribesh
Posts: 1
Joined: Fri Jan 27, 2017 8:41 pm

Re: Openning Serial Ports

Fri Jan 27, 2017 8:50 pm

I did as AndrewS advised. But it lead to "no directory found"; instead from "permission denied".
I'm using Pi model B rev1 Raspbian Pixel

EmmanuelCaster
Posts: 1
Joined: Wed Apr 19, 2017 6:17 pm

Re: Openning Serial Ports

Wed Apr 19, 2017 6:23 pm

Please any update on this issue for Raspbian Jessie Pixel Since /etc/inittab is no longer? plus I already checked this link posting.php?mode=reply&f=66&t=123081&si ... be0bf8126c and I couldn't coin a solution out of it 

klintkrossa
Posts: 62
Joined: Tue Nov 10, 2015 3:06 pm

Re: Openning Serial Ports

Fri Apr 21, 2017 4:08 pm

Hello,

I have noticed that raspi-config the serial port is not enabled. ???? :|
Thanks
This is not like any other bulletin boards that I have been on. Been flamed on other BB's so bad I was afraid to ask.

All my Raspberry Pi's are like the Hessian artilleryman of Sleepy Hollow.

nathan.t.holder
Posts: 1
Joined: Tue Aug 29, 2017 2:46 pm

Re: Openning Serial Ports

Tue Aug 29, 2017 2:48 pm

timhoffman wrote:
Fri Aug 03, 2012 1:18 am
Hi

You need to use /dev/ttyAMA0

But this requires you do a few things.

1.Make sure your userid (default is pi) is a member of the dialout group. (which your usermod command did)
2. You need to stop the getty running on the GPIO serial console.

To do this you need
- remove references to /dev/ttyAMA0 from /boot/cmdline.txt - which sets up the serial console on boot.
In my case old contents

Code: Select all

dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 rootwait
and new contents

Code: Select all

dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 rootwait
Also you need to disable the getty on that serial port in /etc/inittab
Comment out the following line

Code: Select all

#2:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100
Oh and reboot ;-)

Cheers

Tim
Does not exist on my raspbian machine!
/etc/inittab

User avatar
DougieLawson
Posts: 29323
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: Openning Serial Ports

Tue Aug 29, 2017 10:32 pm

/etc/inittab hasn't existed since Jessie arrived with systemd - two years ago.

The console getty is started with a systemd service file.
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

Since 2012: 1B*5, 2B*2, B+, A+, Zero*2, 3B*3

Please post ALL technical questions on the forum. Do not send private messages.

Return to “Python”

Who is online

Users browsing this forum: No registered users and 13 guests