How transmit and receive data through Rx and Tx pins

Moderators: mdrjr, odroid

How transmit and receive data through Rx and Tx pins

Unread postby PashaShulga » Sun Mar 13, 2016 12:33 am

Hello.

I am need to write python code for transmit and receive data (characters and digits). Maybe someone has already done this task?
PashaShulga
 
Posts: 5
Joined: Sun Mar 13, 2016 12:20 am
languages_spoken: english

Re: How transmit and receive data through Rx and Tx pins

Unread postby odroid » Sun Mar 13, 2016 8:31 am

There is no UART example for Python.

But you can find some useful methods. https://github.com/hardkernel/Odroid-US ... _usb_io.py
Code: Select all
def ser_test(dev):            # check if a char available on serial port
def ser_putc(dev,schar):      # send a char to the serial port
def ser_puts(dev, strval):    # send a string to the serial port
def ser_getc(dev):            # get a single char from the serial port
User avatar
odroid
Site Admin
 
Posts: 24355
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID

Re: How transmit and receive data through Rx and Tx pins

Unread postby gbrown » Tue Aug 22, 2017 7:21 am

I too need to communicate over TTL UART to control my instrument PCB (bidirectional level shifting built in).
I'd like to avoid going thru USB to UART only because it seems like it should be unnecessary.
I run Ubuntu16 and python2.7 on XU4

The example code I found is:
import wiringpi2 as wpi
wpi.wiringPiSetup()
while True:
wpi.serialOpen('/dev/ttySAC0',115200)
wpi.serialPuts(serial,"Any old string")
wpi.serialClose(serial)
wpi.delay(500)
I ran this code and also tried RTS/CTS loopback, but scope shows nothing on TX from XU4.

Can someone point me to what I did not initialize. For instance, where is 8bit, no stop bit, hardware handshake set up?
I followed the leads below but did not find relevant answers.
This Linux world is along way from my microprocessor background, so I request the patience of any correspondent.
Thanks, Graham.
gbrown
 
Posts: 17
Joined: Tue Jun 27, 2017 3:50 am
languages_spoken: english, french, some spanish
ODROIDs: XU-4

Re: How transmit and receive data through Rx and Tx pins

Unread postby odroid » Tue Aug 22, 2017 7:59 am

@gbrown

Please don't hijack.
Open a new thread on XU4 Ubuntu sub-forum.
User avatar
odroid
Site Admin
 
Posts: 24355
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID


Return to USB IO

Who is online

Users browsing this forum: No registered users and 1 guest