I am a newbie with pyserial and in general with serial communication. Help with the following problem would be appreciated:
I have a temperature controller which, according to the manufacturer, incorporates a USB brigde controller CH341 to receive commands via the usb connected device. The manufacturer supplies a (buggy) software to remotely control the device.
Now i would prefer to not use that software but rather utilize python with pyserial.
From the windows device manager i can look up the port settings which i subsequently use for my pyserial configuration.
In addition i worked with a serial sniffer to receive the strings(?) that were send when changing the temperature utilizing the manufacturer’s software.
E.g. via the sniffer i saw the command to change the temperature to 10.5degC is: 01 06 00 00 00 69 49 E4. Here the 69 translates to 105.
My expectation is that when i send the string/bytes that the temperature changes to 10.5degC - which is not the case.
Can anyone please point out the issue here or give me guidance towards the right direction?
The code is as follows:
import serial
ser = serial.Serial()
ser.baudrate = 9600
ser.port = „COM3“
ser.timeout = 5
ser.stopbits
ser.open()
#Serial<id=0x233e6e2e1a0, open=True>(port=„COM3“, baudrate=9600, bytesize=8, parity=„N“, stopbits=1, timeout=5, xonxoff=False, rtscts=False, dsrdtr=False)
ser.readline()
#b““
#ser.write(b“01 06 00 00 00 69 49 E4“) #before i received the hint from comment below @jasonharper
#23
ser.write(bytes.fromhex(“01 06 00 00 00 69 49 E4“))
#8
I tried ser.readline() and was expecting any temperature ready but received only b““.
I tried to write the previously via a serial-port-sniffer received hex-code ser.write(bytes.fromhex(“01 06 00 00 00 69 49 E4“))* and expected the temperature setting to change on the temperature controller display just like when utilizing the manufacturers software but it did not take the new temperature.
*correction implemented from comment below @jasonharper
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Update, more detail:
The Port settings/configurations used i copied from the device manager when utilizing the manufacturers software: Port settings used for configuring serial port via pyserial
The commands i want to send via pyserial were beforehand "sniffed" via a port sniffer. Below is the information received from the sniffer when communicating with the temperatur controller via the manufacturers software. Note that the hex string in bold letters (01 04 03 E8 00 01 B1 BA, 01 04 03 EE 00 01 51 BB, 01 03 00 32 00 01 25 C5, 01 04 03 EB 00 01 41 BA) are constantly written/send to the temperature controller via the manufacturers software. The cursive hex string (01 06 00 00 00 69 49 E4) is the one being send once i put in the value 10.5degC into the manufacturers software.
<p class="st03">119740058: 2024-02-23 19:51:04.5865028 +0.0060389
</p>
<table width="100%" cellspacing="0" cellpadding="0" border="0"><tr><td valign="top" class="st05"><pre> **01 04 03 E8 00 01 B1 BA**</pre></td>
<td valign="top" class="st05"><pre>...è..±º</pre></td></tr></table>
<p class="st03">119744798: 2024-02-23 19:51:04.6644844 +0.0054975
</p>
<table width="100%" cellspacing="0" cellpadding="0" border="0"><tr><td valign="top" class="st05"><pre> *01 06 00 00 00 69 49 E4*</pre></td>
<td valign="top" class="st05"><pre>.....iIä</pre></td></tr></table>
<p class="st03">120232312: 2024-02-23 19:51:14.7767970 +0.0378926
</p>
<table width="100%" cellspacing="0" cellpadding="0" border="0"><tr><td valign="top" class="st05"><pre> **01 04 03 EE 00 01 51 BB**</pre></td>
<td valign="top" class="st05"><pre>...î..Q»</pre></td></tr></table>
<p class="st03">119750188: 2024-02-23 19:51:04.7416770 +0.0055397
</p>
<table width="100%" cellspacing="0" cellpadding="0" border="0"><tr><td valign="top" class="st05"><pre> **01 03 00 32 00 01 25 C5**</pre></td>
<td valign="top" class="st05"><pre>...2..%Å</pre></td></tr></table>
<p class="st03">119755664: 2024-02-23 19:51:04.8179006 +0.0057432
</p>
<table width="100%" cellspacing="0" cellpadding="0" border="0"><tr><td valign="top" class="st05"><pre> **01 04 03 EB 00 01 41 BA**</pre></td>
<td valign="top" class="st05"><pre>...ë..Aº</pre></td></tr></table>
<p class="st03">119761074: 2024-02-23 19:51:04.8964708 +0.0064898
</p>