Pyserial Issues with Python3.7 and Fluke Multimeter - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Data Science (https://python-forum.io/forum-44.html) +--- Thread: Pyserial Issues with Python3.7 and Fluke Multimeter (/thread-11398.html) Pages:
1
2
|
Pyserial Issues with Python3.7 and Fluke Multimeter - jfisher930 - Jul-06-2018 Hello All, I am having issues running a very simple code to a Fluke 8846A Multimeter. very curious as to what is wrong with such a simple code. Any help would be much appreciated import serial import time ser = serial.Serial() ser.baudrate = 9600 ser.bytesize = 8 ser.stopbits = 1 ser.xonxoff = 0 ser.rtscts = 0 ser.timeout = None ser.port = "COM4" parity=serial.PARITY_NONE ser.open() print ("Connection to Fluke successful") ser.write('SENS:VOLT:RANG 10 \r\n') time.sleep(2) print(ser.readline(10)) ser.close() print ("Connection Severed") RE: Pyserial Issues with Python3.7 and Fluke Multimeter - jfisher930 - Jul-06-2018 Thank you Larz60+, i will be sure to correctly post in the future. Here is the error i am seeing. Looking up this error it seems that i should be using the following: ser.write('SENS:VOLT:RANG 10 \r\n'.encoder())but using this function causes an endless loop after the time sleep command RE: Pyserial Issues with Python3.7 and Fluke Multimeter - volcano63 - Jul-06-2018 Did your try without \r ? AFAIK, only Windows uses \r\n as EOL sequenceOne more thing I have noticed - you don't actually initialize parity attribute - it is not part of ser object, just a standalone variable - though this is the default value. And initializing all attributes during object creations looks like a proper wayser = serial.Serial("COM4", 9600)It looks that you use default values for the rest of parameters anyway - see the docs RE: Pyserial Issues with Python3.7 and Fluke Multimeter - jfisher930 - Jul-06-2018 Ive tried both \r\n and \n both still providing the same error. My machine is capable of taking in any either <CR> , <LF> or the combination of <CR><LF> Adding the code you recommended above and eliminating my default settings provides Even when i try to manually close the port before running the code, the same error comes up so i have reverted back to my original settings
RE: Pyserial Issues with Python3.7 and Fluke Multimeter - volcano63 - Jul-06-2018 (Jul-06-2018, 09:18 PM)jfisher930 Wrote: Even when i try to manually close the port before running the code, the same error comes up so i have reverted back to my original settingsI did not state that your original settings are the issue - I just pointed out that they are mostly redundant (only the port and baudtrate have non-default values). I prefer to write as little as possible code - but that's my lazy ass But, after some research, I found that 3.7 is not listed as a supported version, the latest supported version is 3.6. Going for the latest and the greatest Python version without checking compatibility may be a major problem (just had a person complaining in another forum about numpy misbehaving in 3.7 - turned out he has installed the version for 3.6)
RE: Pyserial Issues with Python3.7 and Fluke Multimeter - DeaD_EyE - Jul-07-2018 Quote:But, after some research, I found that 3.7 is not listed as a supported version, the latest supported version is 3.6. Going for I'm using Python 3.7 with numpy, numba, scipy, flask, pyserial, zmq, aiohttp, websockets, nidaqmx, multiprocessing, threading on Windows 10 in production. The only problem I have with pyserial is a dying port, but this happened also with Python 3.6. The com port I'm using is an integrated Arduino on the board. It should work also with other COM ports. If you're able to open the port again, then send bytes and not a str. ser.write(b'SENS:VOLT:RANG 10 \r\n')or ser.write('SENS:VOLT:RANG 10 \r\n'.encode()) RE: Pyserial Issues with Python3.7 and Fluke Multimeter - jfisher930 - Jul-09-2018 [quote='DeaD_EyE' pid='51872' dateline='1530950771'] Quote:If you're able to open the port again, then send bytes and not a str. I have tried both of the suggested approaches and it just causes a loop to occur at the readline for whatever reason. Updated Code: import serial import time ser = serial.Serial() ser.baudrate = 9600 ser.bytesize = 8 ser.stopbits = 1 ser.xonxoff = 0 ser.rtscts = 0 ser.timeout = None ser.port = "COM4" parity=serial.PARITY_NONE ser.open() print ("Connection to Fluke successful") ser.write('MEAS:VOLT:RANG 10 \r\n'.encode()) time.sleep(2) print ("Time Sleep successful") print(ser.readline()) ser.close() print ("Connection Severed")
RE: Pyserial Issues with Python3.7 and Fluke Multimeter - sayjenson - Dec-04-2018 [Good evening, i am beginner to use python language. I have interested to get more detail for connecting fluke 8846A and computer. Can you provide more tutorial about that to let me learn? RE: Pyserial Issues with Python3.7 and Fluke Multimeter - DeaD_EyE - Dec-04-2018 If you buy me one, I'll make the tutorial for you :-) The main pain point are Bytes vs Strings when using transports like network or serial. I guess this was also problem with his loop. Maybe he tried to compare strings and bytes of equality. RE: Pyserial Issues with Python3.7 and Fluke Multimeter - sayjenson - Dec-06-2018 can i email to you for more information? |