-1

Hey I am trying to work with the serial port of my raspberry pi model 2B with a raspbian jesse OS. I have disabled the serial login shell over serial in the advanced options. I have enabled uart in the config.txt. However I am noticing that my dmseg command is not working, and I do not have access to ttySX ports or ttyUSB ttyAMA ports. Can someone explain this to me?

When I type dmseg | grep tty, it says dmseg: command not found.

If I cannot write serially to these ports is there a way I can add the missing ports, because when I look through the boot/cmdline.txt I see console = serial0, 115200 console = tty1. What are these consoles? I appreciate any help.

The program i am running is

import serial

port = serial.Serial("/dev/tty1", baudrate=115200, timeout=3.0)

while True:
    port.write("\r\nSay something:")
    rcv = port.read(10)
    port.write("\r\nYou sent:" + repr(rcv))
Zotto
  • 45
  • 1
  • 6
  • Without details of the OS you are running the question is unclear. One thing that is clear is that /dev/tty1 is NOT a serial port. – Milliways Jul 12 '16 at 06:27
  • raspbian jesse is the OS, also I just noticed that when I shutdown my pi, and the GUI vanished I saw the output of my program correctly, but because I have been changing the code over the course of the time it was on I do not know which port was the correct one. Is there a way to view my pi without the GUI without having to shut it down? – Zotto Jul 12 '16 at 06:37

2 Answers2

0

The following is about the Pi3, but does explain about the serial ports How-do-i-make-serial-work-on-the-raspberry-pi3

If you are using a recent Raspbian the default serial port is /dev/serial0 - /dev/ttyAMA0 on older releases.

Milliways
  • 59,890
  • 31
  • 101
  • 209
  • When I compile when writing to dev/serial0 I get a serial exception, and it tells me no suck file or directory /dev/serial0 – Zotto Jul 12 '16 at 06:44
0

Switching the port to dev/tty without any numbers for some reason allowed the code to function correctly. That was harder than I wanted it to be, thanks for the help though.

Zotto
  • 45
  • 1
  • 6
  • You really want to work out what you are trying to achieve. dev/tty is NOT a serial port. It is a character mode device, normally a console, and you can write to it. It will not output on the serial pins (8,10) unless the console is also mapped to the serial port. This will not be useful, as anything you output will be mixed with console messages. – Milliways Jul 12 '16 at 07:10
  • Ok that makes more sense now, but why cant I see the ttySX ports? – Zotto Jul 12 '16 at 07:19
  • I don't know why you are expecting to see these. ttyUSB and ttySx ports are generally associated with additional peripherals such as USB2serial adapters or other extensions. – Milliways Jul 12 '16 at 07:23
  • if I add an XBee using a dongle extension would I see an additional ttySx port? – Zotto Jul 12 '16 at 07:32
  • Please accept your own answer with a click on the tick on its left side. Only this will finish the question and it will not pop up again year for year. – Ingo Jan 03 '20 at 12:54