I made a client for my wwm called worldzord,
I need help for it here is its code
#Worldzord client V1.0
from array import array
import socket
import time
HOST = '127.0.0.1'
PORT = 42001
def sendScratchCommand(cmd):
n = len(cmd)
a = array('c')
a.append(chr((n >> 24) & 0xFF))
a.append(chr((n >> 16) & 0xFF))
a.append(chr((n >> 8) & 0xFF))
a.append(chr(n & 0xFF))
scratchSock.send(a.tostring() + cmd)
print("connecting...")
scratchSock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
scratchSock.connect((HOST, PORT))
print("connected")
print ("Please type in your scratch syntax for help, see the source code")
myName = input()
sendScratchCommand(myName)
print("the command: " + myName + " was sent to scratch sucessfully!")
time.sleep(0.5)
#help:
#remote sensor syntax: sensor-update "var name" value
#brodcast syntax: brodcast "name here"For some reason I keep getting this error
Traceback (most recent call last):
File "C:\Users\Zeus\Desktop\python client.pyw", line 24, in <module>
sendScratchCommand(myName)
File "C:\Users\Zeus\Desktop\python client.pyw", line 11, in sendScratchCommand
a = array('c')
ValueError: bad typecode (must be b, B, u, h, H, i, I, l, L, f or d)
can somebody fix this code and also make it so it repeats forever?
Last edited by flashgocrazy (2011-12-18 17:26:58)
Offline
flashgocrazy wrote:
I made a client for my wwm called worldzord,
I need help for it here is its codeCode:
#Worldzord client V1.0 from array import array import socket import time HOST = '127.0.0.1' PORT = 42001 def sendScratchCommand(cmd): n = len(cmd) a = array('c') a.append(chr((n >> 24) & 0xFF)) a.append(chr((n >> 16) & 0xFF)) a.append(chr((n >> 8) & 0xFF)) a.append(chr(n & 0xFF)) scratchSock.send(a.tostring() + cmd) print("connecting...") scratchSock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) scratchSock.connect((HOST, PORT)) print("connected") print ("Please type in your scratch syntax for help, see the source code") myName = input() sendScratchCommand(myName) print("the command: " + myName + " was sent to scratch sucessfully!") time.sleep(0.5) #help: #remote sensor syntax: sensor-update "var name" value #brodcast syntax: brodcast "name here"For some reason I keep getting this error
Traceback (most recent call last):
File "C:\Users\Zeus\Desktop\python client.pyw", line 24, in <module>
sendScratchCommand(myName)
File "C:\Users\Zeus\Desktop\python client.pyw", line 11, in sendScratchCommand
a = array('c')
ValueError: bad typecode (must be b, B, u, h, H, i, I, l, L, f or d)can somebody fix this code and also make it so it repeats forever?
You have python 3 don't you?
Downgrade to 2.7
Offline
It seems you have a wrong type of typecode. Try one of them that the error suggested.
Offline
nickbrickmaster wrote:
It seems you have a wrong type of typecode. Try one of them that the error suggested.
I got the same thing when I had Python 3.3
I downgraded and it all went away
Offline
I haven't used Python 3, but instead of a = array('c') try a = ['c']. It may/should work.
Offline
Magnie wrote:
I haven't used Python 3, but instead of a = array('c') try a = ['c']. It may/should work.
I think I tried that when I had Python 3, but it didn't work...I think all that does is create an array with one index: 'c'
But it's worth a try
Offline
TRocket wrote:
is this mesh or remote sensor connections?
Mesh with Remote Sensors I think.
Offline