Python Forum
Send raw string via socket with out any changes
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Send raw string via socket with out any changes
#1
Hi,
I have problem with sending raw string data via socket. I made communication between PC(python script) and labeler Markem Imaje. Labeler has RS232 and converter Ethernet/RS232 and i have to send raw string data to converter with out any changes for example:

\x01\x81\xaa\x76\x00\x5d\x44\x00\x00\x00\x00\x57\x47\x5f\...

if I do something like this is working and labeler take mesage:

if labeler_connect_status:
    try:
        labeler_socket.send(b'\x01\x81\xaa\x76\x00\x5d\x44\x00\x00\x00\x00\x57\x47\x5f\...')
        print('DATA_SEND')
    except:
        print('ERROR_SEND')
        labeler_connect_status = False
but I have many different message and i want put raw string to variable:

if labeler_connect_status:
    variable = \x01\x81\xaa\x76\x00\x5d\x44\x00\x00\x00\x00\x57\x47\x5f\...
    try:
        labeler_socket.send(b'variable')#I know it doesn't work, but I want something like that
        print('DATA_SEND')
    except:
        print('ERROR_SEND')
        labeler_connect_status = False
I tried many options Wall but it doesn't work because python try to encodes my data to UTF-8, ASCII...
for example when I want change string to bytes
\x01\x81\xaa\x76\x00\x5d\x44\x00\x00\x00\x00\x57\x47\x5f\... python send:
b'\x01\xc2\x81\xc2\xaav\x00]D\x00\x00\x00\x00WG_

My question is, how can I send raw data string as bytes with out any changes?
PLS help

P.S. I tried make variable string with b' - variable = b'\x01\x81\xaa\x76\x00\x5d\x44\x00\x00\x00\x00\x57\x47\x5f\' - but it didn't work
Reply


Messages In This Thread
Send raw string via socket with out any changes - by john36 - Jul-21-2019, 08:18 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Send data BMP180 between client and server trought module socket smalhao 0 2,834 Jul-30-2018, 12:56 PM
Last Post: smalhao
  Simple send and recive string Server/Client Epilepsy 1 2,736 May-01-2018, 08:17 PM
Last Post: ThiefOfTime

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020