This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
uart ttyS1
#1
Hello,

I try to use serial port ttyS1, I have change value in extlinux.conf with:

label kernel-4.4
    kernel /zImage
    fdt /rk3288-miniarm.dtb
    append earlyprintk root=/dev/mmcblk0p2 rw init=/sbin/init

In Idle python3 I run this :

import serial

ser = serial.Serial("/dev/ttyS1",9600)

print(ser.name)         

while (2)  :    

    ser.write(b"hello world")

    print(ser.read)

    print("test serial")
    ser.close()

and in the Shell I can read this:

/dev/ttyS1

<bound method Serial.read of Serial<id=0xb52278f0, open=True>(port='/dev/ttyS1', baudrate=9600, bytesize=8, parity='N', stopbits=1, timeout=None, xonxoff=False, rtscts=False, dsrdtr=False)>

test serial

Traceback (most recent call last):

  File "/home/linaro/Documents/test_serial 3.py", line 6, in <module>

    ser.write(b"hello world")

  File "/usr/lib/python3/dist-packages/serial/serialposix.py", line 517, in write

    raise portNotOpenError
serial.serialutil.SerialException: Attempting to use a port that is not open

Please help me!
I run on tinkerOs!
I set jumper in pin 8 & 10!
And In tinker board configuration uart1: on uart2: off uart3: on uart4:on
all of other communication turning off!
 Thanks,
Reply
#2
Have you test the port by shorting pin 8 and 10. There should be your input echoed back. That's will give the idea whether the UART is working. Later you should make sure that you got the permission to access that device. So you might try
Code:
$ sudo chmod 666 /dev/ttyS1
Light blue words might be a link. Have you try to click on them? Big Grin
Reply
#3
thanks for reply,

I shorting pin 8 &10. It's same result (with and without)
I test whit: sudo chmod 666 /dev/ttyS1 and go back to under line.
but I test programme whit debugger:
KeyError:'serial'
'importlib._bootstrap.'_get_module_lock(),line 182:
Reply
#4
I have test on other version(python2.7) and it run.
Reply
#5
That's the limit of some program which is not ported to python 3.7
Light blue words might be a link. Have you try to click on them? Big Grin
Reply
#6
Hi Mathelis

I can reproduce your issue.
please follow my steps, you can see the result at console.
linaro@tinkerboard:~$ python test.py
hello world
test serial
hello world

steps:
1. make sure "intf:uart4=on" at /boot/hw_intf.conf
2. shorting pin 13 &15
3. try the test code as below:

Code:
import time
import serial

ser = serial.Serial('/dev/ttyS4',9600)

while (2)  :
    ser.close()
    ser.open()
    ser.write(b"hello world")
    print(ser.read(11))
    time.sleep(1)
    print("test serial")
thank you.

Reply
#7
Hi,
Thanks for the script, I can't tell you if it run before,
I test with uart1 and uart4 and it run.
I can see in the shell :hello world
test serial
It's Good,
Thanks,
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)