I am trying to establish communication with electrical test equipment for remote control and data logging with a python script. I am unable to even get off the ground. It looks like I am unable to open the port? Any help is appreciated.
I am on a Windows machine using VSCode terminal.
PS C:\Users\AaronVaughan> py -m serial.tools.list_ports
COM6
1 ports found
>>> import serial
>>> ser = serial.Serial(port="COM6")
...
serial.serialutil.SerialException: could not open port 'COM6': FileNotFoundError(2, 'The system cannot find the file specified.', None, 2)
After acquiring the address, serial number, and version of the instrument, I gained access using pyvisa and libusb1. The address, SN, and ver. were acquired after driver installation from National Instruments and the device manufacturers website.
Some skeleton code below...
import pyvisa
rm = pyvisa.ResourceManager()
PM1 = rm.open_resource("USB0::0x0A69::0x0879::63212AL00409::INSTR")
PM1.write_termination = '\n'
PM1.read_termination = '\n'
PM1.timeout = 1000
PM1.write('*CLS')
print(PM1.query('*IDN?'))
PM1.write('*RST')
Related
I am trying to connect M210 v2 RTK to a desktop computer with Ubuntu 18.04, ROS Melodic and parallel installation of Opencv 3.3.1 and 4.5.3 using a USB-TTL RS232 to make UART connection and an USB-USB connecting drone and desktop to be able to run Advanced Sensing.
When I call ls -l /dev/ttyACM* && ls -l /dev/ttyUSB* it returns that it is indentified the USB and ACM connection.
crw-rw---- 1 root dialout 166, 0 out 4 13:18 /dev/ttyACM0
crw-rw---- 1 root dialout 188, 0 out 4 13:18 /dev/ttyUSB0
I also set the transfer rate of TTL-USB to 921600 using minicom, and gave persmission to device to read and write with sudo usermod -a -G dialout $USER && sudo chmod 666 /dev/ttyUSB0
Unfortunatelly when I launch roslaunch dji_osdk_ros dji_sdk_node.launch it appears some connection problem presented below and I am not being able to fix it. I have been trying to turn on/off drone and RC several times ass described here, but the problem still stand.
started roslaunch server http://V3D06:43613/
SUMMARY
========
PARAMETERS
* /dji_sdk/acm_name: /dev/ttyACM0
* /dji_sdk/align_time: False
* /dji_sdk/app_id: 1076017
* /dji_sdk/app_version: 1
* /dji_sdk/baud_rate: 921600
* /dji_sdk/dxc: False
* /dji_sdk/enc_key: 6bd1d26f8dd897e4b...
* /dji_sdk/serial_name: /dev/ttyUSB0
* /dji_sdk/use_broadcast: False
* /rosdistro: melodic
* /rosversion: 1.14.12
NODES
/
dji_sdk (dji_osdk_ros/dji_sdk_node)
auto-starting new master
process[master]: started with pid [2436]
ROS_MASTER_URI=http://localhost:11311
setting /run_id to bde7b4d2-252e-11ec-8a59-1831bfb3e154
process[rosout-1]: started with pid [2458]
started core service [/rosout]
process[dji_sdk-2]: started with pid [2464]
[ INFO] [1633364323.534426789]: Advanced Sensing is Enabled on M210.
Read App ID
User Configuration read successfully.
[1276751.089]STATUS/1 # getDroneVersion, L1702: ret = 0
[1276751.089]STATUS/1 # parseDroneVersionInfo, L1122: Device Serial No. = 1DADG3E00100U4
[1276751.089]STATUS/1 # parseDroneVersionInfo, L1124: Firmware = 3.4.3.44
[1276751.089]STATUS/1 # functionalSetUp, L279: Shake hand with drone successfully by getting drone version.
[1276751.089]STATUS/1 # legacyX5SEnableTask, L56: Legacy X5S Enable task created.
[1276752.089]STATUS/1 # sendHeartbeatToFCTask, L1576: OSDK send heart beat to fc task created.
[1276752.289]STATUS/1 # Control, L40: The control class is going to be deprecated.It will be better to use the FlightController class instead!
[1276752.290]STATUS/1 # FileMgrImpl, L253: register download file callback handler successfully.
[1276753.557]STATUS/1 # PSDKModule, L98: MOP only support M300, so mop client will not be initialized here.
[1276753.557]STATUS/1 # PSDKModule, L98: MOP only support M300, so mop client will not be initialized here.
[1276753.557]STATUS/1 # PSDKModule, L98: MOP only support M300, so mop client will not be initialized here.
[1276753.557]STATUS/1 # initDJIHms, L900: DJI HMS is not supported on this platform!
[1276753.567]STATUS/1 # getDroneVersion, L1702: ret = 0
[1276753.567]STATUS/1 # parseDroneVersionInfo, L1122: Device Serial No. = 1DADG3E00100U4
[1276753.567]STATUS/1 # parseDroneVersionInfo, L1124: Firmware = 3.4.3.44
[1276753.567]STATUS/1 # AdvancedSensing, L145: Advanced Sensing init for the M210 drone
[1276753.567]STATUS/1 # init, L49: Looking for USB device...
[1276753.572]STATUS/1 # init, L65: Found 8 USB devices, identifying DJI device...
[1276753.572]STATUS/1 # init, L83: Found a DJI device...
[1276753.572]STATUS/1 # init, L96: Attempting to open DJI USB device...
[1276753.572]ERRORLOG/1 # init, L101: Failed to open DJI USB device...
[1276753.572]ERRORLOG/1 # init, L102: Error code: -3
[1276753.572]ERRORLOG/1 # init, L105: Please make sure you provide a udev file for your system and reboot the computer
[1276753.573]STATUS/1 # LiveViewImpl, L89: Finding if liveview stream is available now.
[1276754.076]STATUS/1 # init, L254: Start advanced sensing initalization
[1276754.076]STATUS/1 # activate, L1329: version 0x304032C
[1276754.076]STATUS/1 # adv_pthread, L46: adv pthread created !!!!!!!!!!!!!!!!!!!!!!!
[1276754.076]STATUS/1 # adv_pthread, L48: adv pthread running !!!!!!!!!!!!!!!!!!!!!!!
[dji_sdk-2] process has died [pid 2464, exit code -11, cmd /home/vant3d/catkin_ws/devel/lib/dji_osdk_ros/dji_sdk_node __name:=dji_sdk __log:=/home/vant3d/.ros/log/bde7b4d2-252e-11ec-8a59-1831bfb3e154/dji_sdk-2.log].
log file: /home/vant3d/.ros/log/bde7b4d2-252e-11ec-8a59-1831bfb3e154/dji_sdk-2*.log
It appears it has some problem providing a udev file, but I don't know how to fix it. Does anyone have some idea to help on this problems?
Thank you!
That's my post. Firstly turn off advanced sensing to try whether a basic FTDI works.
The second which DJI OSDK version are you using? does the OSDK version match the version in OSDK-ROS? I saw you have M300 in. that is usually in OSDK 4+. For M210, I only use 3.8 and 3.9
If basic FTDI works, and you can get all the feedback. there is a higher chance that you have the wrong ACM config. DJI RNDIS thing is nasty and may not be config properly. You need to manually set static IP of 192.168.43.1 (or I remember something like this 42 or 43, you need to check on this static IP) and set it manually
As the title states I get an error trying to communicate from a Raspberry PI 4 and windows system using an SSL connection.
The current client script works perfectly on windows to a server application running on windows.
This is the client script:
from OpenSSL import SSL
import sys, os, select, socket, time
ctx = SSL.Context(SSL.SSLv23_METHOD)
sock = SSL.Connection(ctx, socket.socket(socket.AF_INET, socket.SOCK_STREAM))
sock.connect(('10.0.0.84', 443))
stri = 'hello\r\n'
tobyte = bytes(stri,'utf-8')
print(tobyte)
buf = sock.recv(4096)
while True:
sock.send(tobyte)
time.sleep(60)
The error I get on Raspberry Pi 4:
Traceback (most recent call last): File
"/home/pi/Documents/scripts/openssltest.py", line 15, in
buf = sock.recv(4096)
File "/usr/lib/python3/dist-packages/OpenSSL/SSL.py", line 1791, in recv
self._raise_ssl_error(self._ssl, result) File "/usr/lib/python3/dist-packages/OpenSSL/SSL.py", line 1647, in
_raise_ssl_error
_raise_current_error() File "/usr/lib/python3/dist-packages/OpenSSL/_util.py", line 54, in
exception_from_error_queue
raise exception_type(errors) OpenSSL.SSL.Error: [('SSL routines', 'ssl_choose_client_version', 'unsupported protocol')]
I have the same version of OpenSSL running on the Raspberry Pi and Windows PC
One thing I noticed in Visual Studio Code (for the Raspberry Pi) is that the sock.send() is not recognised but sock.sendall() is. VSC in windows is showing sock.send() as an option.
I am using OpenSSL version 1.1.1k and python 3.7.3 on the Raspberry PI. OpenSSL 1.1.1k and python 3.9.6 on windows. All devices are running on the same network
I have not written the server application but uses a self signed certificate.
Any suggestions would be much appreciated
Adding #mti2935 comment as the answer as this fixed my problem. Just to help anyone in the future
('SSL routines', 'ssl_choose_client_version', 'unsupported protocol')
usually means the server will only allow connections using certain
SSL/TLS protocols (e.g. TLS1.2 or above), but the client does not
support any of the protocols that the server requires (e.g. client
supports TLS1.0 or lower). Can you try connecting to the server from
the command line of the PI, by doing openssl s_client -connect
10.0.0.84:443? Does it connect? If so, what protocol does it use?
The problem was that my client was using a protocol that the server did not support SSLv23_METHOD. Changed the protocol to SSL.TLSv1_METHOD.
Corrected code:
from OpenSSL import SSL
import sys, os, select, socket, time
ctx = SSL.Context(SSL.TLSv1_METHOD)
sock = SSL.Connection(ctx, socket.socket(socket.AF_INET, socket.SOCK_STREAM))
sock.connect(('10.0.0.84', 443))
stri = 'hello\r\n'
tobyte = bytes(stri,'utf-8')
print(tobyte)
buf = sock.recv(4096)
print(buf)
while True:
sock.send(tobyte)
time.sleep(5)
As title mentioned, I tried to extract some data from AMG8833 through GPIO on Jetson nano, but always get
[Errno 121]Remote I/O error...
My AMG8833 SDA connect to GPIO pin 27, and SCL connect to pin 28. I have already tried
sudo i2cdetect -y -r 1
Then only shows 29, I have no idea about this, and still cannot work...
Is there anyone has any other solutions about this issue? Please share with me, I will be very appreciated for your help.
Following is the python code...
import busio
import time
import board
import adafruit_amg88xx
i2c = busio.I2C(board.SCL, board.SDA)
amg = adafruit_amg88xx.AMG88XX(i2c)
while True:
time.sleep(1)
for row in amg.pixels:
# Pad to 1 decimal place
print(["{0:.1f}".format(temp) for temp in row])
print(row)
print("")
print("\n")
time.sleep(1)
I am establishing serial communication using raspberry Pi with ADAM-4520 device using pyserial lib using usb to serial converter.
1st,I tested device with PC using hyper terminal and with Pi using Gtkterm,
To read sensor values from device with command "#04".
Here i first giving output from Gtkterm.
#04
>+261.25+310.76+049.09+206.77+126.80+049.79
#04
>+261.25+310.76+049.09+206.75+126.80+049.79
But when i am trying through Pyserial program it isn't working.
Here is my code:
import serial
import time
s=serial.Serial(port='/dev/ttyUSB0',
baudrate=9600,
parity=serial.PARITY_NONE,
stopbits=serial.STOPBITS_ONE,
bytesize=serial.EIGHTBITS,
timeout=1)
st="#04"
st=''.join(str(ord(c)) for c in st)
x=st.encode('ascii')
while True:
s.write(x)
print(x)
time.sleep(0.2)
text=s.readline()
temp=text.decode('ascii')
#text=text.decode('utf-8')
#text=text[5:-1]
print(temp)
time.sleep(2)
As both hyper terminal and gtkterm work with ascii ,i am also tried to convert my command into ascii also but no result.
i am new to python ,please guide to find the issue guys
pi#raspberrypi:~ $ sudo python3 helloworld.py
b'354852'
b'354852'
b'354852'
i want to make a monitoring program for tracer
i use rs485 usb converter to connect epever tracer1210a to raspberry pi 3 model b
from pymodbus.client.sync import ModbusSerialClient as ModbusClient
client = ModbusClient(method = 'rtu', port = '/dev/ttyACM0', baudrate = 115200)
client.connect()
print( client)
result = client.read_input_registers(0x3100,6,unit=1)
print (result)
solarVoltage = float(result.registers[0] /100.0)
solarCurrent = float(result.registers[1] /100.0)
batteryVoltage = float(result.registers[4] /100.0)
chargeCurrent = float(result.registers[5] /100.0)
print("solar voltage : ",solarVoltage)
print("solar current : ",solarCurrent)
print("battery volatage : ",batteryVoltage)
print("charge current : ",chargeCurrent)
client.close()
and i get error like this:
ModbusSerialClient(rtu baud[115200])
Modbus Error: [Input/Output] Modbus Error: [Invalid Message] Incomplete message received, expected at least 2 bytes (0 received)
Traceback (most recent call last):
File "yutub.py", line 9, in
solarVoltage = float(result.registers[0] /100.0)
AttributeError: 'ModbusIOException' object has no attribute 'registers'
please help me to fix this problem
I had faced the same problem.
Follow the below steps to fix the issue:
git clone https://github.com/kasbert/epsolar-tracer/tree/master/xr_usb_serial_common-1a
Follow the installation steps from Readme.
You might face problem when you execute make. In such case do sudo apt-get install linux-headers.
Check that the USB UART is detected by the system
lsusb
Check that the CDC-ACM driver was not installed for the Exar USB UART
ls /dev/tty*
To remove the CDC-ACM driver and install the driver:
sudo rmmod cdc-acm
sudo modprobe -r usbserial
sudo modprobe usbserial
sudo insmod ./xr_usb_serial_common.ko
After this when you do ls /dev/tty* you will see /dev/ttyXRUSB0. This means the driver is installed and you are in good shape.
Change the port in your code to '/dev/ttyXRUSB0'.
See the output image
After you restart the PI you might not see the ttyXRUSB0 instead you will see ttyACM0. In such case execute sudo echo blacklist cdc-acm > /etc/modprobe.d/blacklist-cdc-acm.conf. If PI does not allow you to execute then create the file in the path and write blacklist cdc-acm.
Reboot and verify if ttyACM0 is still displayed in ls /dev/tty*.