Kjo
Posts: 4
Joined: Wed Apr 13, 2016 5:12 pm

Freeing up the serial port

Tue Apr 19, 2016 9:53 pm

Hi
I have a raspberry pi B and am trying to free up my serial port. I'm able to do what I need to in "sudo nano /boot/cmdline.txt". But when I try to do what I need to do in "sudo nano /etc/inittab" it says that it is a new file and has no content. I'm totally confused and could really do with some help, thanks.

User avatar
MarkHaysHarris777
Posts: 1820
Joined: Mon Mar 23, 2015 7:39 am
Location: Rochester, MN
Contact: Website

Re: Freeing up the serial port

Wed Apr 20, 2016 3:24 am

Kjo wrote:But when I try to do what I need to do in "sudo nano /etc/inittab" it says that it is a new file and has no content
Take a look here, then come back and ask if you still have questions.
marcus
:ugeek:

DirkS
Posts: 10362
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: Freeing up the serial port

Wed Apr 20, 2016 9:17 am

Kjo wrote:Hi
I have a raspberry pi B and am trying to free up my serial port. I'm able to do what I need to in "sudo nano /boot/cmdline.txt". But when I try to do what I need to do in "sudo nano /etc/inittab" it says that it is a new file and has no content. I'm totally confused and could really do with some help, thanks.
If you're running Raspbian then

Code: Select all

sudo raspi-config
Option Advanced / Serial / No should take care of that...

driff
Posts: 2
Joined: Sun Apr 24, 2016 12:50 am

Re: Freeing up the serial port

Sun Apr 24, 2016 5:36 am

This does remove the serial console, but if a python script tries to open the port it complains that the port is already open, I had to close the port before my code would work. I didn't need to do that before a recent reinstall and upgrade to kernel 4.4.8

Here is a snippet of my fixed code:

Code: Select all

import serial

ser = serial.Serial('/dev/ttyAMA0', 115200 , timeout=2) #, write_timeout=2) #blocking time out 2s
try:
  ser.open()
except serial.SerialException as err:
  print err
  print "closing port"
  try:
    ser.close()
    ser.open()
  except serial.SerialException as er2:
   print "failed twice " + er2
print "Opening serial port"
give this output:

Code: Select all

Port is already open.
closing port
Serial port opened

Kjo
Posts: 4
Joined: Wed Apr 13, 2016 5:12 pm

Re: Freeing up the serial port

Mon Apr 25, 2016 6:29 pm

Thank you so much to all those who haved helped :) :D

Return to “Beginners”