Hi All,
I have built a system to control some point motors for a model railway using a series of picaxe chips to control a transistor to allow the points to change.
To control these I have written a program in python that communicates over the standard serial communications setup (I disconnect the chip to use the download wiring for communications).
I am having a confusing issue however. When the Chip receives ">RSET" from the PC that means I want all the chips to reset (and turn all outputs off). When i send this command using Termite all works perfectly fine I get the acknowledgement back from the picaxe chips and then their boot up confirmation, so all good.
When i send the same through python I get the initial acknowledgement that the picaxe chips have received the command and are resetting. But once they reset everything goes wrong. The python program ends up freezing. I have found out that this is due to the picaxe chips sending a constant stream of jibberish back to the pc.
I checked this by triggering the reset from my python program, disconnecting and then using Termite to view what was being read in on the serial port.
I have absolutely no idea why on Termite it works but through python it doesn't. here are my codes;
Picaxe code;
so basically the picaxe chips are daisy chained together so that the PC sends the command to the first chip, which then repeats the message out to the next one in the line.
and the python side;
termite settings are;
Baud 9600,
8 data bits
1 stop bit
no parity
no flow control
no forward
append LF (in the transmitted text section)
Im not sure why it works for terminte but not python when they are both sending the exact same command
Any help would be greatly appreciated
I have built a system to control some point motors for a model railway using a series of picaxe chips to control a transistor to allow the points to change.
To control these I have written a program in python that communicates over the standard serial communications setup (I disconnect the chip to use the download wiring for communications).
I am having a confusing issue however. When the Chip receives ">RSET" from the PC that means I want all the chips to reset (and turn all outputs off). When i send this command using Termite all works perfectly fine I get the acknowledgement back from the picaxe chips and then their boot up confirmation, so all good.
When i send the same through python I get the initial acknowledgement that the picaxe chips have received the command and are resetting. But once they reset everything goes wrong. The python program ends up freezing. I have found out that this is due to the picaxe chips sending a constant stream of jibberish back to the pc.
I checked this by triggering the reset from my python program, disconnecting and then using Termite to view what was being read in on the serial port.
I have absolutely no idea why on Termite it works but through python it doesn't. here are my codes;
Picaxe code;
Code:
do
serrxd (b6),b1,b2,b3,b4
loop while b1=0 and b2=0 and b3=0
if b1="R" and b2="S" and b3="E" and b4="T" then
sertxd(b6,b1,b2,b3,b4,13,10)
b1=0
serrxd[500],(b7),b1,b2,b3,b4
if b1<>0 then
sertxd(b7,b1,b2,b3,b4,13,10)
end if
sertxd(b7,"ACRS",13,10)
Reset
end if
and the python side;
Code:
globals.s = serial.Serial(globals.comm_port, 9600, timeout=0.5)
globals.s.open()
globals.s.reset_input_buffer()
globals.s.reset_output_buffer()
globals.s.write(b">BSET")
returned = ">"
while not returned[:1] == "<":
returned = globals.s.readline()
globals.s.close()
globals.s = ""
print returned
Baud 9600,
8 data bits
1 stop bit
no parity
no flow control
no forward
append LF (in the transmitted text section)
Im not sure why it works for terminte but not python when they are both sending the exact same command
Any help would be greatly appreciated