problem in using serail port in raspberry model 3


3 posts
by yasamin » Mon Jun 19, 2017 6:58 am
Hi
I use a raspberry pi model 3. I did all of things according to this link:
http://www.instructables.com/id/Read-an ... pberry-Pi/

using a usb-serial converter (PL2303), I connected it to pc and using Putty terminal set to 9600-8N-1 use the c code in the following link in raspberry:
http://www.raspberry-projects.com/pi/pr ... g-the-uart

But the write() function in c code always retun 0. Can you help me? Open() function return fd=3.
thanks
Posts: 1
Joined: Mon Jun 19, 2017 5:29 am
by topguy » Mon Jun 19, 2017 7:47 pm
What devicename do you use in your code ?
You have to verify that its actually the devicename of the PL230x device.
Plug it in after the Pi boots, and look at the last lines of the output of "dmesg" command.
( my guess is that it should be "/dev/ttyUSB0", I belive "ttyACM0" is used by the BT chip on the Raspberry 3.

The filedescriptor will always be 3 for the first file successfully opened by your program.
User avatar
Posts: 3124
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway
by dgordon42 » Thu Jun 22, 2017 8:13 pm
Unfortunately the two web pages of instructions you have linked to are 3 years old, and don't work on a Pi 3B.

First, can you confirm that the USB connection of your usb-serial converter (PL2303) is connected to the Pi and the Serial Port pins are connected to the PC, or is it the other way around?

Post the output of the following commands (to check the configuration of the Pi's Serial Port):
Code: Select all
uname -a
cat /boot/cmdline.txt
grep -v ^\# /boot/config.txt
ls -lh /dev/serial*


Dave.
Posts: 667
Joined: Tue Aug 13, 2013 6:55 pm
Location: Dublin, Ireland