Ok, so i wanna start using the UART pins on the GPIO (GPIO14,15) and i just wanna start walking by looping the tx and rx and sending data to and from my PI.
In a future far far away i plan on having a C program running with an interrupt that is started from a serial command. (but i dont wanna be spoon fed) i just wanna start using UART and build up slowly.
My question is after physically looping TX and RX then what do i do? ( i haven't looped TX and RX in case i need to put something between them)
Thanks in advance
Matt
Re: UART
OK, so i got a bit further with this:
I ran the following code in terminal:
and all i got was
bash: /dev/ttyAMA0: Permission denied
so i tried
same error
bash: /dev/ttyAMA0: Permission denied
I guessing i have a command wrong somewhere, any help?
(also noticing 50 views no replies: am i being stupid is this something that should be easier and people dont wanna offend me, please offend away I'm thick / thick skinned
Matt
I ran the following code in terminal:
Code: Select all
echo - "sent from pi" > /dev/ttvAMA0
bash: /dev/ttyAMA0: Permission denied
so i tried
Code: Select all
sudo echo - "sent from pi" > /dev/ttvAMA0
bash: /dev/ttyAMA0: Permission denied
I guessing i have a command wrong somewhere, any help?
(also noticing 50 views no replies: am i being stupid is this something that should be easier and people dont wanna offend me, please offend away I'm thick / thick skinned
Matt
I assume I know what I`m talking about... I probably don`t
Home: 256mb Made in UK, Rasbmc, 40" Sony Bravia KDL-40v3000
Work: 2b+, Rasbian, 6" Lilliput touchscreen
Home: 256mb Made in UK, Rasbmc, 40" Sony Bravia KDL-40v3000
Work: 2b+, Rasbian, 6" Lilliput touchscreen
Re: UART
ok to be not the 51the in your list:
the builtin serial port is imho (i 'am not a expert neither) used for the logon console.
you have that one turned of becuase the serial is "owned" by the bootloader/kernel (getty)
some ideas are in viewtopic.php?f=44&t=17360
Hope this one helps,
cheers.
the builtin serial port is imho (i 'am not a expert neither) used for the logon console.
you have that one turned of becuase the serial is "owned" by the bootloader/kernel (getty)
some ideas are in viewtopic.php?f=44&t=17360
Hope this one helps,
cheers.
- tedhale
- Posts: 114
- Joined: Thu Sep 20, 2012 4:52 pm
- Location: Williamsburg, VA, USA
- Contact: Website
Re: UART
stedew is correct, another process already has the device open, so you get that error.
Look at my blog post
http://raspberrypihobbyist.blogspot.com ... -port.html
Look at the 2nd half of the post for instructions on how to "free up" the serial port.
Look at my blog post
http://raspberrypihobbyist.blogspot.com ... -port.html
Look at the 2nd half of the post for instructions on how to "free up" the serial port.
- Ted B. Hale
http://raspberrypihobbyist.blogspot.com
http://raspberrypihobbyist.blogspot.com
- tedhale
- Posts: 114
- Joined: Thu Sep 20, 2012 4:52 pm
- Location: Williamsburg, VA, USA
- Contact: Website
Re: UART
BTW,
you will see a lot of views and few posts because most people coming here are looking for answers, not giving them out.
Most likely, the first 50 viewers had no clue how to solve your problem.
I read this forum for two reasons
1. I need to find answers myself sometimes, but mostly
2. I enjoy helping people, so I look for new posts that I can add info to.
you will see a lot of views and few posts because most people coming here are looking for answers, not giving them out.
Most likely, the first 50 viewers had no clue how to solve your problem.
I read this forum for two reasons
1. I need to find answers myself sometimes, but mostly
2. I enjoy helping people, so I look for new posts that I can add info to.
- Ted B. Hale
http://raspberrypihobbyist.blogspot.com
http://raspberrypihobbyist.blogspot.com
Re: UART
thanks guys!
Modified those 2 files and everything works great
http://raspberrypihobbyist.blogspot.co.uk has some great stuff if any1 is reading this looking for similar solutions give that page a look
Modified those 2 files and everything works great
http://raspberrypihobbyist.blogspot.co.uk has some great stuff if any1 is reading this looking for similar solutions give that page a look
I assume I know what I`m talking about... I probably don`t
Home: 256mb Made in UK, Rasbmc, 40" Sony Bravia KDL-40v3000
Work: 2b+, Rasbian, 6" Lilliput touchscreen
Home: 256mb Made in UK, Rasbmc, 40" Sony Bravia KDL-40v3000
Work: 2b+, Rasbian, 6" Lilliput touchscreen
Re: UART
wiringPi has a serial out command that i have found, so if your reading this looking for some sample C code check out
https://projects.drogon.net/raspberry-p ... mment-1116
Gordon floats around the forum so he might pick up questions but his website/blog is so comprehensive I have learnt some great stuff C programming wise!
https://projects.drogon.net/raspberry-p ... mment-1116
Gordon floats around the forum so he might pick up questions but his website/blog is so comprehensive I have learnt some great stuff C programming wise!
I assume I know what I`m talking about... I probably don`t
Home: 256mb Made in UK, Rasbmc, 40" Sony Bravia KDL-40v3000
Work: 2b+, Rasbian, 6" Lilliput touchscreen
Home: 256mb Made in UK, Rasbmc, 40" Sony Bravia KDL-40v3000
Work: 2b+, Rasbian, 6" Lilliput touchscreen
-
- Posts: 4277
- Joined: Sun Jan 15, 2012 1:11 pm
Re: UART
Sort of appropos of nothing, but...
Nobody has commented on this, so I'll pipe in. Note that:
sudo echo foo > /dev/ttyAMA0
won't do what you expect it to, because the shell redirection is performed by your local shell, not by the command run under sudo.
You can verify this by doing (assuming, of course, that plugh doesn't already exist):
sudo touch /tmp/plugh
sudo echo test > /tmp/plugh # Fails
sudo bash
echo test > /tmp/plugh # works
exit
Nobody has commented on this, so I'll pipe in. Note that:
sudo echo foo > /dev/ttyAMA0
won't do what you expect it to, because the shell redirection is performed by your local shell, not by the command run under sudo.
You can verify this by doing (assuming, of course, that plugh doesn't already exist):
sudo touch /tmp/plugh
sudo echo test > /tmp/plugh # Fails
sudo bash
echo test > /tmp/plugh # works
exit
And some folks need to stop being fanboys and see the forest behind the trees.
(One of the best lines I've seen on this board lately)
(One of the best lines I've seen on this board lately)
Re: UART
my objective is want to display the output in my laptop...
this is my coding..
is there any mistake in my coding.Thanks .
this is my coding..
Code: Select all
import serial
ser = serial.Serial("/dev/ttyAMA0",9600)
ser.write("My String outputto serial port")
Re: UART
How have you connected the Pi to the PC/Laptop?
It needs an RS232 converter between GPIO UART and PC/Laptop?
Have you disabled the kernel from using the GPIO UART?
This is detailed in many places and posts in this thread.
It needs an RS232 converter between GPIO UART and PC/Laptop?
Have you disabled the kernel from using the GPIO UART?
This is detailed in many places and posts in this thread.
Just another techie on the net - For GPIO boards see http:///www.facebook.com/pcservicesreading
or http://www.pcserviceselectronics.co.uk/pi/
or http://www.pcserviceselectronics.co.uk/pi/
Re: UART
By the way, it's not
It's
Difference is in the name of the port ( I guess it's a port)
There is ttY, not ttV. Maybe someone will have this problem in future.
Code: Select all
echo - "sent from pi" > /dev/ttvAMA0
Code: Select all
echo - "sent from pi" > /dev/ttyAMA0

There is ttY, not ttV. Maybe someone will have this problem in future.
- FTrevorGowen
- Forum Moderator
- Posts: 5999
- Joined: Mon Mar 04, 2013 6:12 pm
- Location: Bristol, U.K.
- Contact: Website
Re: UART
FWIW (and slightly off-topic) Whilst I havn't done anything much with the Pi's own UART (yet - I'm just starting to do "GPIO things" "at the mo.") I did test out a USB - RS232 cable a while ago and logged it as "working" in the wiki. Some pictures & screenshots etc. are at http://www.cpmspectrepi.webspace.virgin ... apter.html where I'm using a ancient serial printer/terminal to display the output etc. There's also some general "RS232" stuff elsewhere in my webpages that goes "way back".thivtulz wrote: my objective is want to display the output in my laptop...
Trev.
Still running Raspbian Jessie or Stretch on some older Pi's (an A, B1, 2xB2, B+, P2B, 3xP0, P0W, 2xP3A+, P3B+, P3B, B+, and a A+) but Buster on the P4B's & P400. See: https://www.cpmspectrepi.uk/raspberry_pi/raspiidx.htm
Re: UART
Try a Google search for "raspberry uart python"
These hits look useful -
https://sites.google.com/site/semillero ... rials/gpio
http://www.stuffaboutcode.com/2013/09/r ... ython.html
These hits look useful -
https://sites.google.com/site/semillero ... rials/gpio
http://www.stuffaboutcode.com/2013/09/r ... ython.html
How To Ask Questions The Smart Way: http://www.catb.org/~esr/faqs/smart-questions.html
How to Report Bugs Effectively: http://www.chiark.greenend.org.uk/~sgtatham/bugs.html
How to Report Bugs Effectively: http://www.chiark.greenend.org.uk/~sgtatham/bugs.html
- CopterRichie
- Posts: 131
- Joined: Tue Mar 26, 2013 3:14 am
- Location: Los Angeles CA.
Re: UART
Hello one and all, I have a question please. I would like to use the Raspberry Pi to program an Arduino chip directly using /dev/ttyAMA0 however, the Arduino requires the DTR to be toggled prior to uploading the code. So, which GPIO pin on the Raspberry Pi correspond to the DTR?
Thank you.
I will be using the Arduino IDE on the Raspberry PI for programming.
Thank you.
I will be using the Arduino IDE on the Raspberry PI for programming.
Re: UART
I'm not sure the Pi's UART supports DTR.CopterRichie wrote:Hello one and all, I have a question please. I would like to use the Raspberry Pi to program an Arduino chip directly using /dev/ttyAMA0 however, the Arduino requires the DTR to be toggled prior to uploading the code. So, which GPIO pin on the Raspberry Pi correspond to the DTR?
Thank you.
I will be using the Arduino IDE on the Raspberry PI for programming.
Regardless of that can you not choose any spare gpio and call that DTR, i.e. connect it to the Arduino and toggle the line in your code?
- CopterRichie
- Posts: 131
- Joined: Tue Mar 26, 2013 3:14 am
- Location: Los Angeles CA.
Re: UART
I located the following but not sure how to implement it.joan wrote: I'm not sure the Pi's UART supports DTR.
Regardless of that can you not choose any spare gpio and call that DTR, i.e. connect it to the Arduino and toggle the line in your code?
http://www.raspberrypi.org/phpBB3/viewt ... 241#p39241
Re: UART
The solution in the other thread seems to require changing gpios 16/17 to an ALT mode (Alt 5, CTS/RTS) and using them as DSR/DTR.
I don't see the point. To my mind it's simpler to toggle a gpio.
Anyhow there are C libraries to allow you to set the ALT modes if that's what you want to do.
I don't see the point. To my mind it's simpler to toggle a gpio.
Anyhow there are C libraries to allow you to set the ALT modes if that's what you want to do.
- CopterRichie
- Posts: 131
- Joined: Tue Mar 26, 2013 3:14 am
- Location: Los Angeles CA.
Re: UART
I think but not sure, the Arduino IDE toggles both the DTR and the CTS lines. So I might be ok, will have to test to be sure.
Thank you for the assistance.
Thank you for the assistance.
- Richard-TX
- Posts: 1549
- Joined: Tue May 28, 2013 3:24 pm
- Location: North Texas
Re: UART
I am going out on a limb anticipating the nest question.
To change the speed of the uart one has to open the device and then change the speed using an ioctl call or issue a stty command depending on the programming language. Closing the device and reopening it results in it reverting back to the default settings.
To change the speed of the uart one has to open the device and then change the speed using an ioctl call or issue a stty command depending on the programming language. Closing the device and reopening it results in it reverting back to the default settings.
Richard
Doing Unix since 1985.
The 9-25-2013 image of Wheezy can be found at:
http://downloads.raspberrypi.org/raspbian/images/raspbian-2013-09-27/2013-09-25-wheezy-raspbian.zip
Doing Unix since 1985.
The 9-25-2013 image of Wheezy can be found at:
http://downloads.raspberrypi.org/raspbian/images/raspbian-2013-09-27/2013-09-25-wheezy-raspbian.zip
Re: UART
For those wanting a python way to program Raspberry Pi for UART
http://radiostud.io/understanding-raspb ... unication/
http://radiostud.io/understanding-raspb ... unication/
Re: UART
Some docs here, but this is a very old thread...
https://www.raspberrypi.org/documentati ... on/uart.md
https://www.raspberrypi.org/documentati ... on/uart.md
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.