makerportal / tfluna-python

Python codes for TF-Luna LiDAR module that interface with a Raspberry Pi computer
21 stars 12 forks source link

testing out TFLuna and Pi4 #3

Open resistorsoftware opened 3 years ago

resistorsoftware commented 3 years ago

Hi,

just checking but the GPIO UART setting on my Raspberry Pi helper diagram has TX on pin 8 and RX on Pin 10, yet the TFLuna shows pin 2 as RX and 3 as TX. So in the hookup diagram I am seeing Tuna pin 2 (RX) going to GPIO pin 8 (TX). Is that correct? TX Tuna to RX GPIO and correspondingly RX Tuna to TX GPIO?

I copied the config Python in Thonny, and tried the config file out and it fails. I am not sure why. New to Pi and Tuna.

Traceback (most recent call last): File "/home/pi/Documents/config.py", line 115, in set_samp_rate(100) # set sample rate 1-250 File "/home/pi/Documents/config.py", line 36, in set_samp_rate ser.write(samp_rate_packet) # send sample rate instruction AttributeError: 'NoneType' object has no attribute 'write'

So I am attemptiung to take measurements with Lidar and this is my first messages... any clue as to what that means?

I checked for the UART and ls -l shows dev/serial0 but initially when I tried out the code I got:

Traceback (most recent call last): File "/home/pi/Documents/config.py", line 110, in prev_ser = serial.Serial("/dev/serial0", baudrates[prev_indx],timeout=0) # mini UART serial device File "/usr/local/lib/python3.7/dist-packages/serial/serialutil.py", line 244, in init self.open() File "/usr/local/lib/python3.7/dist-packages/serial/serialposix.py", line 325, in open raise SerialException(msg.errno, "could not open port {}: {}".format(self._port, msg)) serial.serialutil.SerialException: [Errno 13] could not open port /dev/serial0: [Errno 13] Permission denied: '/dev/serial0'

So I am not sure why a device would not have permission, but a sudo chmod 777 naively seemed to make that go away. What am I doing wrong?