Sending data over a socket

Hey all this is probably super simple but I can’t figure it out for the life of me.

I am trying to make a program that sends data to FiveM (GTA multiplayer client), essentially like a macro without the need to open a chat dialogue and enter a command, which for what I’m using it for, is over port “29200” and is sent from my PC only. I developed the program in python while I was in Canada not thinking about the fact that a Pico doesn’t run python (I know Mpy and Cpy is similar, but for this instance not what I need) and it worked fine,

here is the code that worked to send the data:

while True:
            print('q is pressed')
HOST = "localhost"  
PORT = 29200  # devcon port (29200)

    with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
        s.connect((HOST, PORT))
        s.send(bytes.fromhex('43 4d 4e 44 00 d2 00 00 00 00 00 19 00 00 73 65 74 72 61 64 69 6f 20 31 30 00'))
        data = s.recv(1024)

Which gave the exact data I was looking to send, I even tested this in game and it executed the command I needed it to.

However whenever I try get it to work on a Pico (regular and Pico W today) I cannot for the life of me get it to work.

Any help is appreciated :slight_smile:

1 Like

Hi Levi,

Would it be possible to get all of the code that are running?

If you wrap everything from the with statement in a try except exception catcher what returns?

Hey Liam,
I’ve got code all over the place and am way out of my depth, I’m unsure if I should be trying to use the networking features of a Pi Pico W, or if I should go some other way. Would I be able to have some assistance to write the code from scratch?