Page 2 of 2

Re: Pi 3 Serial Issues

Posted: Tue May 15, 2018 9:53 pm
by dgordon42
@marciokoko,
Nice try, but no.

The Pi uses one of it's serial ports to communicate with the Bluetooth Controller chip. It sends and receives low level data and instructions to/from the chip. Unfortunately, you can't just fire data at the chip and expect it to communicate it to another device over Bluetooth.

It should be possible to establish a connection over Bluetooth to another device using the Linux Bluetooth software on the Pi, but it is something I have never done. Perhaps someone with Bluetooth knowledge (Douglas6?) might be able to show you how.

Dave.

Re: Pi 3 Serial Issues

Posted: Tue May 15, 2018 10:08 pm
by Douglas6
Dgordon42, thanks for all your help. I'm working with marciokoko in another thread.

Re: Pi 3 Serial Issues

Posted: Fri Sep 07, 2018 9:02 am
by anshumantech
I am working on GPS module connected to Raspberry pi 3 via serial pins Tx, Rx with coding in Python 3.5.3 but i got following errors while i was trying to execute the code:
1. when i gave command as print (rcv.decode('ascii')) then i got error as “unicodedecodeerror:'ascii' codec can't decode the byte 0xff in position 0:ordinal not in range(128)” but when i gave command as print(rcv.decode('ascii','ignore')) then no error but it didn't print expected NMEA sentence data of GPS module.
2. if i removed the decode command then it gives the output in binary as given in doc file below.
I have attached pictures of errors and the code this code is working on Python 2.7 well but on python 3.5.3 it is not working. Please suggest any solution.

Re: Pi 3 Serial Issues

Posted: Fri Sep 07, 2018 1:17 pm
by dgordon42
Python2 and Python3 handle ASCII and Unicode characters differently.
After the line:

Code: Select all

rcv = port.read(400)
in your code, add the line:

Code: Select all

rcv.encode('utf-8')
and see what happens.

Good Luck,
Dave.

Re: Pi 3 Serial Issues

Posted: Mon Sep 10, 2018 5:51 am
by anshumantech
I have checked with the command rcv.decode('utf-8') after rcv = port.read() but it was giving error as "bytes object has no attribute as encode".

Re: Pi 3 Serial Issues

Posted: Mon Sep 10, 2018 10:26 am
by dgordon42
anshumantech wrote:I have checked with the command rcv.decode('utf-8') after rcv = port.read() but it was giving error as "bytes object has no attribute as encode".
That is why I wanted you to try encode. Python2 will print bytes as ASCII characters, but Python3 will not. You need to encode the bytes into UTF-8 characters for Python3 to print them. That is what the "b'" characters in your output is trying to tell you, Python3's print function is not sure what to do with a byte, so it just prints "b". encode should change the bytes into UTF-8 characters so Python3 can print them.

Good Luck.
Dave.