Mahruz
Member level 1
- Joined
- May 16, 2022
- Messages
- 34
- Helped
- 0
- Reputation
- 0
- Reaction score
- 1
- Trophy points
- 8
- Activity points
- 399
Hi Fvm,I don't see a RS PRO SLM1352P manual, do you have it?
still no code and no description ...and
* showing your actual command / python code
and
* telling exactly what you expect and what happens instead.
port = 'COM6',
baudrate = 39400,
timeout = 1,
Hi,
Thanks for the informations. Now we have soemthing to work with.
One mistake:
you code says:
--> please change baudrate to "38400"Code:port = 'COM6', baudrate = 39400, timeout = 1,
I expect the baudrate mismatch to cause wrongly received bytes.
Thus - before further investigstion - you need to repeat the test with the corrected baud rate setup.
*******
Instead of posting a .PNG --> please post the receiver output as text, best if formatted as code. Please press the [C O D E ] butten then copy and paste the message.
(do the same when uploading your code)
Some worries:
* please make the output to be displayed as HEX. Most of the output already seems to be so, but there are additional characters like "U" and "i" and "!" .. I could not explain for now.
For sure your python code needs to be completed to detect the frames sent by the meter. The frame should look like this:
"0x02; data0; data1; data2, data3; 0x03"
it needs to detect 0x02 as frame START and 0x03 as frame END.
******
But first let´s see how the correct baud rate setting will perform...
Klaus
import time
import serial
# Obtained the below information from the Manual
ser = serial.Serial(
port = 'COM6',
baudrate = 38400,
timeout = 1,
parity=serial.PARITY_NONE,
stopbits=serial.STOPBITS_ONE,
bytesize=serial.EIGHTBITS
)
ser.isOpen()
## Write data to SLM 1352P Sound Level Meter
## Fast / Slow
ser.write(bytearray(b'D\r')) #--> This command works and updates can be seem on the SLM 1352P Sound Level Meter display
time.sleep(2)
## Level up
ser.write(bytearray(b'E\r')) #--> This command works and updates can be seem on the SLM 1352P Sound Level Meter display
time.sleep(2)
## Level down
ser.write(bytearray(b'F\r')) #--> This command works and updates can be seem on the SLM 1352P Sound Level Meter display
time.sleep(2)
## Reading the data from the serial port.
## This will be running in an infinite loop.
while 1 :
bytesToRead = ser.inWaiting()
data = ser.read(bytesToRead)
time.sleep(1)
print(data)
# decode_data = data.decode()
# print(decode_data)
b''
b'\x02\x03!\x02`\x03\x02\x03!\x02`\x03\x02\x03!\x02d\x03'
b'\x02\x03!\x02d\x03\x02\x03!\x02c\x03\x02'
b'\x03!\x02c\x03\x02\x03!\x02c\x03\x02\x03!\x02^\x03'
b'\x02\x03!\x02^\x03\x02\x03!\x02^\x03\x02\x03!\x02q\x03'
b'\x02\x03!\x02q\x03\x02\x03!\x02h\x03'
b'\x02\x03!\x02h\x03\x02\x03!\x02h\x03\x02\x03!\x02a\x03'
b'\x02\x03!\x02a\x03\x02\x03!\x02a\x03\x02\x03!\x02n\x03'
b'\x02\x03!\x02n\x03\x02\x03!\x02a\x03'
b'\x02\x03!\x02a\x03\x02\x03!\x02a\x03\x02\x03!\x02W\x03'
How can I change the code to make it display HEX?
Basically I recommend to read byte by byte.This is the part where I am not confident on how to understand and decode the packets. Is there something that I can refer to, to better understand how to decode packets using python?
byte(1) = byte(2); byte(2) = byte(3); byte(3) = byte(4); byte(4) = byte(5); byte(5) = byte(6); byte(6) = ser.read(1);
// this generates the same byte order as in the manual, page #2
if ((byte(1) == 0x02) AND (byte(6) == 0x03)) --> // then you may assume the frame in the buffer is correct
... next step is to process the bytes(2) ... byte(5)
if ((byte(2) AND 0x07) == 0x00) --> min = 80;
if ((byte(2) AND 0x07) == 0x01) --> min = 70;
if ((byte(2) AND 0x07) == 0x02) --> min = 60;
... and so on
max = min + 60;
... and so on
35 2025-01-15 15:59:52.383414 0.205174 IRP_MJ_READ UP 0x102 02 03 20 02 5b 03 .. .[.
36 2025-01-15 15:59:52.749789 0.366335 IRP_MJ_READ UP 0x102 02 03 20 02 55 03 .. .U.
38 2025-01-15 15:59:53.122535 0.372544 IRP_MJ_READ UP 0x102 02 03 20 02 55 03 .. .U.
40 2025-01-15 15:59:53.505112 0.382413 IRP_MJ_READ UP 0x102 02 03 20 02 55 03 .. .U.
42 2025-01-15 15:59:53.878926 0.373593 IRP_MJ_READ UP 0x102 02 03 20 02 42 03 .. .B.
44 2025-01-15 15:59:54.248446 0.369265 IRP_MJ_READ UP 0x102 02 03 20 02 42 03 .. .B.
46 2025-01-15 15:59:54.622671 0.374062 IRP_MJ_READ UP 0x102 02 03 20 02 42 03 .. .B.
48 2025-01-15 15:59:55.013211 0.390305 IRP_MJ_READ UP 0x102 02 03 20 02 83 03 .. ...
50 2025-01-15 15:59:55.394792 0.381312 IRP_MJ_READ UP 0x102 02 03 20 02 83 03 .. ...
52 2025-01-15 15:59:55.758396 0.363550 IRP_MJ_READ UP 0x102 02 03 20 02 43 03 .. .C.
54 2025-01-15 15:59:56.134659 0.376106 IRP_MJ_READ UP 0x102 02 03 20 02 43 03 .. .C.
56 2025-01-15 15:59:56.505623 0.370877 IRP_MJ_READ UP 0x102 02 03 20 02 43 03 .. .C.
58 2025-01-15 15:59:56.895157 0.389449 IRP_MJ_READ UP 0x102 02 03 20 02 55 03 .. .U.
60 2025-01-15 15:59:57.257807 0.362344 IRP_MJ_READ UP 0x102 02 03 20 02 55 03 .. .U.
62 2025-01-15 15:59:57.631789 0.373811 IRP_MJ_READ UP 0x102 02 03 20 02 48 03 .. .H.
64 2025-01-15 15:59:58.014031 0.382012 IRP_MJ_READ UP 0x102 02 03 20 02 48 03 .. .H.
if ((byte(2) AND 0x07) == 0x00) --> min = 80;
The datasheet is rather clear in this:where did you get 0x07 from?
instead of
if ((byte(2) AND 0x07) == 0x00) --> min = 80;
you also could write
if ((byte(2) AND 0b00000111) == 0b00000000) --> min = 80; the "AND" masks (=selects) the lower 3 bits,
--> the same way as aboveIf I change the "A/C" on the instrument, then 20 changes to 00(A). if I press it again, then it changes to 20(C)
weighting = 'A' // preset for 0x00 = "A"
if ((byte(3) AND 0b01100000) == 0b00100000) -->weighting = 'C'; the "AND" masks (=selects) the bits 5 and 6,
if ((byte(3) AND 0b01100000) == 0b01000000) -->weighting = 'Z'; the "AND" masks (=selects) the bits 5 and 6,
if ((byte(3) AND 0b01100000) == 0b01100000) -->weighting = 'F'; the "AND" masks (=selects) the bits 5 and 6,
.. if you did what I told you to do ....Is there a way to decode Byte 4 and Byte 5 using python?
Show the output. And also please give the reading of the meter´s display ... so we know what value it means
As soon as you tell me what´s the dislayed (reading of the meter) value ... I can answer your question.02 03 20 02 42 03
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?