Asked
Resolved Resolved by DJ Sures!

Running Pycharmt To Connect To EZB And Call A Script?

How to write python on pyCharm to connect to EZM using socket and then run a command, voice, script etc.?

I do not get any errors, just nothing happens lol

import socket

Define ARC system's IP address and port

host = '192.168.1.22' # Replace with the ARC system's IP address port = 23 # Replace with the ARC system's port (usually 23)

try: # Create a socket connection arc_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) arc_socket.connect((host, port))

# Specify the path to the ARC script
arc_script_path = "C:\\Users\\your_username\\Documents\\ARC\\My Projects\\test.ezb"  # Replace with the correct path

# Send the ARC script execution command
arc_script = f"RunScript({arc_script_path})"
arc_socket.send(arc_script.encode())

# You may not receive a response immediately, but you can add a delay or loop to check for a response if needed

# Close the socket connection
arc_socket.close()

except socket.error as e: print(f"Socket error: {e}") except Exception as e: print(f"An error occurred: {e}")


Related Hardware EZ-B v3

ARC Pro

Upgrade to ARC Pro

Stay on the cutting edge of robotics with ARC Pro, guaranteeing that your robot is always ahead of the game.

PRO
Synthiam
#9   — Edited

Control command requires double quotes

you escape a double quote with a \ backslash

#10  

You are brilliant.... and I figured it out thank you... this is what i have thus far... if there is a cleaner way let me know. this will now move the head of the robot, speak in it's voice, get information from my PC, pick a random bible verse, speak it and then move the head back to it's original place

from ARCClient import ARCClient import time import bible

server_ip = '127.0.0.1' server_port = 6666

command = 'SayEZB("Good day Terry, here is your bible quote for today")\n'

command1 = 'ServoSpeed(d0, 1)\n' command2 = 'Servo(d0, 1)\n' command3 = 'controlCommand("BingChat", "Track_1")\n'

vline = bible.line verse = bible.get_bible(vline) quoted_output = f'"{verse}"' quoted_output = quoted_output.replace('\n', ' ').replace('\r', '') print(quoted_output)

command4 = f'SayEZB({quoted_output})\n' command5 = 'Servo(d0, 180)\n'

arc_client = ARCClient(server_ip, server_port) arc_client.connect() response = arc_client.send_command(command1) response = arc_client.send_command(command2) response = arc_client.send_command(command3) time.sleep(3.5) response = arc_client.send_command(command4) time.sleep(3.5) response = arc_client.send_command(command5) print("Received response:", response) arc_client.close()