last day (26 days later) » 

11:39 PM
-1
Q: I have facing issues to send and receive hex values to port via serial RS-232

sushant sawantI'm facing issues to send the hex values and receive hex values to serial port. I'm trying to communicate with the OSA device. I tried all things in python serial: \#message = '\xaa\x53\x43\x43\x42\x00\x05\x00\x01\x00\x02\xc5\xb0\x00\x03\xa1\x6b\x03\xa7' \#message = 'aa 53 43 43 42 00 05 00 01 ...

 
You will have to explain what the issue actually is.
 
i'm receiving null values like b' ' b' '
 
What does this “OSA” device expect to recieve, and how does/should it respond to that? What make and model is the device? Do you know the device itself is actually working? Have you tried a simple loopback of the serial output back to the serial input to ensure that your send and receive are working? Why are you encoding what is (Should be?) presumably binary data to utf-8?
Here’s a permutation you appear not to have tried: message = b'\xaa\x53\x43\x43\x42\x00\x05\x00\x01\x00\x02\xc5\xb0\x00\x‌​03\xa1\x6b\x03\xa7' And then change (newmessge).encode(‘utf-8’) to newmessage
But try that loopback first!
 
@barny i need to send hex data to the device osa(optical spectrum analyser) which is when i send hex values to it the device will be respond with also hex values. the device is working with the serial port utility software which is on windows . im trying to communicate with the raspi
 
OK so get the basics working - that loopback. Maybe your USB serial port needs flow control lines like RTS/CTS and you haven’t got them enabled. 460800 is a very unusual baud rate, is that really correct?
 
11:39 PM
@barny thanks but this command is not working
 
Which command is not working?
 
@barny yes baud rate is correct . how to unable RTS/CTS ?? b'\xaa\x53\x43\x43\x42\x00\x05\x00\x01\x00\x02\xc5\xb0\x00\x‌​03\xa1\x6b\x03\xa7' this is not working i tried before
 
Read the pyserial documentation.
 
@barny i read the documentation . but i dont know how to control flow . can you help me plzz
 
If you point to a link for the brand and model of your OSA maybe we can help you to double-check your settings
 
11:39 PM
my OSA is goumax osa
@MarcosG. did you saw ?
 
Just saw, I'm on it
 
@MarcosG. thanx man plzz reply soon
@MarcosG. did you got it bro?
 
The manual says you don't need flow control. I did not have much time, but you can try receivedMessage = serialport.read(serialport.in waiting())
 
@MarcosG. i tried that bro. anyways thanx if you got another method then tell me after some time
 
Are you sure you are making the right wiring?
 
11:39 PM
@MarcosG. i'm confused about sending hex data to port but when i use serial port utility software its responds nicely
 
OK, have you tried adding a return at the end of the message with \r or \r\n?
 
@MarcosG. yes i added this in my question which i posted
 

  last day (26 days later) »