[SOLVED] UART as /dev/ttyS4 not available - Please help!
On Ubuntu 16.04 , Here's what I get
sudo setserial -g /dev/ttyS[0123456789]
/dev/ttyS0, UART: unknown, Port: 0x03f8, IRQ: 4
/dev/ttyS1, UART: unknown, Port: 0x02f8, IRQ: 3
/dev/ttyS2, UART: unknown, Port: 0x03e8, IRQ: 4
/dev/ttyS3, UART: unknown, Port: 0x02e8, IRQ: 3 ---- S4 & S5 missing
/dev/ttyS6, UART: unknown, Port: 0x0000, IRQ: 0
/dev/ttyS7, UART: unknown, Port: 0x0000, IRQ: 0
/dev/ttyS8, UART: unknown, Port: 0x0000, IRQ: 0
/dev/ttyS9, UART: unknown, Port: 0x0000, IRQ: 0
=======================================================
kahren@kahren-UP-APL01:~/kampr-face-access-control$ dmesg | grep tty
[ 0.000000] console [tty0] enabled
[ 5.261289] dw-apb-uart.8: ttyS4 at MMIO 0x91524000 (irq = 4, base_baud = 115200) is a 16550A
[ 5.261475] serial serial0: tty port ttyS4 registered
[ 5.280603] dw-apb-uart.9: ttyS5 at MMIO 0x91522000 (irq = 5, base_baud = 115200) is a 16550A
[ 5.280833] serial serial1: tty port ttyS5 registered
=====================================================
yet when I do
import serial
ComPort = serial.Serial('/dev/ttyS4')
ComPort.baudrate = 115200
ComPort.bytesize = 8
ComPort.parity = 'N'
ComPort.stopbits = 1
data = ComPort.readline()
print("data : {}".format(data) )
ComPort.close()
I get --- FileNotFoundError: [Errno 2] No such file or directory: '/dev/ttyS4'
I really would appreciate guidance here! One thing to note, when I installed ubuntu 16.04.6 the instructions indicated to replace generic kernel but the listed command failed ... is the kernel the issue here?
Thanks,
Kahren
Comments
-
the issue was with the kernel .. fixed it and now /dev /ttyS4 is visible... at this point I don't get any data with CTS pulled to GND and the following code running on the UpBoard,, Note from my laptop I write bytearray(b'X') to USB to RS485 ... on the UpBoard side there is RS485 <--> TTL adapter that has TxD and RxD on the TTL side to UpBoard ... No other signals like RTS, CTS ... I see the TxD LED come on on the laptop side's adapter, I see the RxD LED on the UpBoard side adapter BUT my program below is waiting for dataAvailable... I am using pin 8 Tx and pin 10 Rx, pin 1 or 2 for Vcc and pin 6 GND .... any help would be appreciated!!!
import mraa
import sys
import timeclass RS485(object) :
"""
TODO
"""
#define UART parameters
BAUD_RATE = 9600 #115200
BYTE_SIZE = 8
PARITY = 'N'
STOP_BITS = 1
RTSCTS = False #True
XONXOFF = False
BREAK_DURATION = 30 # Check OSDP specdef __init__(self): """ TODO """ print("mraa version : {}".format(mraa.getVersion()) ) mraa.init() print("In UART init") # initialise UART self.uart = mraa.Uart("/dev/ttyS4") print ("/dev/ttyS4 Uart initialized") device_path = self.uart.getDevicePath() print("device path is : {}".format(device_path) ) # Set UART parameters self.uart.setBaudRate(RS485.BAUD_RATE) print("baudrate set") self.uart.setMode(RS485.BYTE_SIZE, mraa.UART_PARITY_NONE, RS485.STOP_BITS) print("setmode complete") self.uart.setFlowcontrol(RS485.XONXOFF, RS485.RTSCTS) print("setFlowControl complete") print("done with UART class instantiation")
def main():
"""
Entry point of program
"""
rs485 = RS485()
print("returned from init")# Start a neverending loop waiting for data to arrive. # Press Ctrl+C to get out of it. while True: data_ready = rs485.uart.dataAvailable() print ("data_ready = {}".format(data_ready) ) if data_ready: # We are doing 1-byte reads here data_byte = rs485.uart.readStr(1) print(data_byte) # Just a two-way half-duplex communication example, "X" is a flag if data_byte == "X": rs485.uart.writeStr("Yes, master!")
# else:
# rs485.uart.writeStr("Hi!")time.sleep(0.5)
if name == "main":
sys.exit(main()) -
Taking the idea from another thread, I isolated everything except the UART, connected UART_tx and UART-Rx pins 6 & 8 and ran sudo echo "hello world" /dev/ttyS4 and from another terminal ran sudo cat -v /dev/ttyS4 and nothing is received ... Does this mean my UART is bad?
-
Hi @KahrenA ,
Could you please confirm the BIOS version and the kernel version?
1. uname -a
2. cat /etc/*release
3. dmesg | grep BIOS -
thank you for your quick response... below are what you asked for ...
uname -a
Linux kahren-UP-APL01 4.15.0-37-generic #40~upboard03-Ubuntu SMP Wed Dec 12 16:21:24 UTC 2018 x86_64 x86_64 x86_64 GNU/Linuxcat /etc/*release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04.6 LTS"
NAME="Ubuntu"
VERSION="16.04.6 LTS (Xenial Xerus)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 16.04.6 LTS"
VERSION_ID="16.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
VERSION_CODENAME=xenial
UBUNTU_CODENAME=xenialdmesg | grep BIOS
[ 0.000000] e820: BIOS-provided physical RAM map:
[ 0.000000] BIOS-e820: [mem 0x0000000000000000-0x000000000003efff] usable
[ 0.000000] BIOS-e820: [mem 0x000000000003f000-0x000000000003ffff] reserved
[ 0.000000] BIOS-e820: [mem 0x0000000000040000-0x000000000009dfff] usable
[ 0.000000] BIOS-e820: [mem 0x000000000009e000-0x00000000000fffff] reserved
[ 0.000000] BIOS-e820: [mem 0x0000000000100000-0x000000000fffffff] usable
[ 0.000000] BIOS-e820: [mem 0x0000000010000000-0x0000000012150fff] reserved
[ 0.000000] BIOS-e820: [mem 0x0000000012151000-0x0000000077b38fff] usable
[ 0.000000] BIOS-e820: [mem 0x0000000077b39000-0x0000000079c56fff] reserved
[ 0.000000] BIOS-e820: [mem 0x0000000079c57000-0x0000000079c6bfff] ACPI data
[ 0.000000] BIOS-e820: [mem 0x0000000079c6c000-0x0000000079ccbfff] ACPI NVS
[ 0.000000] BIOS-e820: [mem 0x0000000079ccc000-0x000000007a024fff] reserved
[ 0.000000] BIOS-e820: [mem 0x000000007a025000-0x000000007a070fff] type 20
[ 0.000000] BIOS-e820: [mem 0x000000007a071000-0x000000007a3defff] usable
[ 0.000000] BIOS-e820: [mem 0x000000007a3df000-0x000000007a3dffff] ACPI NVS
[ 0.000000] BIOS-e820: [mem 0x000000007a3e0000-0x000000007a409fff] reserved
[ 0.000000] BIOS-e820: [mem 0x000000007a40a000-0x000000007a964fff] usable
[ 0.000000] BIOS-e820: [mem 0x000000007a965000-0x000000007a966fff] reserved
[ 0.000000] BIOS-e820: [mem 0x000000007a967000-0x000000007affffff] usable
[ 0.000000] BIOS-e820: [mem 0x000000007b000000-0x000000007fffffff] reserved
[ 0.000000] BIOS-e820: [mem 0x00000000d0000000-0x00000000d0ffffff] reserved
[ 0.000000] BIOS-e820: [mem 0x00000000e0000000-0x00000000efffffff] reserved
[ 0.000000] BIOS-e820: [mem 0x00000000fe042000-0x00000000fe044fff] reserved
[ 0.000000] BIOS-e820: [mem 0x00000000fe900000-0x00000000fe902fff] reserved
[ 0.000000] BIOS-e820: [mem 0x00000000fec00000-0x00000000fec00fff] reserved
[ 0.000000] BIOS-e820: [mem 0x00000000fed01000-0x00000000fed01fff] reserved
[ 0.000000] BIOS-e820: [mem 0x00000000fee00000-0x00000000fee00fff] reserved
[ 0.000000] BIOS-e820: [mem 0x00000000ff000000-0x00000000ffffffff] reserved
[ 0.000000] BIOS-e820: [mem 0x0000000100000000-0x000000017fffffff] usable
[ 0.000000] efi: ACPI=0x79c5e000 ACPI 2.0=0x79c5e000 SMBIOS=0x79edd000 SMBIOS 3.0=0x79edc000
[ 0.000000] SMBIOS 3.0.0 present.
[ 0.000000] DMI: AAEON UP-APL01/UP-APL01, BIOS UPA1AM21 09/01/2017
[ 0.000000] Calgary: detecting Calgary via BIOS EBDA area
[ 2.504180] intel_idle: Please enable MWAIT in BIOS SETUP
[ 2.600392] BIOS EDD facility v0.16 2004-Jun-25, 0 devices found
kahren@kahren-UP-APL01:~$ -
any obvious issue? should i upgrade my bios? if so to 4.0 or 4.6?
-
SOLVED!! turns out to be a silly thing.. I need to use ttyS5 and not ttyS4 ... the wiki community pint out page says otherwise... WHY?
http://wiki.up-community.org/Pinout#UART_Example_.231 -
Hi @KahrenA ,
Thank you for the contribution.
We will check it and redefine the UP Wiki example.