Ahh, I see, thanks! I was thinking of doing something like
indata=serial.read(1) while indata != "?" or indata != "G" data += indata
in the download function. I'm not sure if that's proper Python grammar, but you get the idea. Could be done with if as well, but I think your echo_write suggestion is better.
On Mon, Apr 29, 2013 at 5:13 PM, Dan Smith dsmith@danplanet.com wrote:
I'm working on adding support for a new radio, the Ritron RTX-450. It's a commercial radio, but with a bit of VCO tinkering works in the ham bands.
Cool!
I started with template.py, and use uv5r.py as a reference, since I have one of those as well. So far, I've mapped out the memory and established communication with the radio, but I'm having a problem when I read the data. To establish communication, I first send a series of "?", followed by a "G". As soon as the radio receives the G, it starts sending data. What's happening in chirp, though, is when I do the serial.read(1), I'm getting the sent data back and then the radio data, as if the buffer doesn't clear. This uses an Icom OPC-478 style cable, where RX and TX are simply wire-OR'd together, so that does make sense. I should mention that this cable works fine with the OE software. Do I just need to look for the sent string in the response and filter it out, or is there a better way to handle this? I tried inserting serial.flush() after serial.write("G"), but when stepping through the program that seemed to do nothing.
Yeah, so those sorts of cables "echo" because of the unified TX/RX line. So, the best way to hand that is something like:
def _echo_write(radio, data): radio.pipe.write(data) radio.pipe.read(len(data))
and use _echo_write(radio, "foo") instead of radio.pipe.write("foo") in your communication. Various permutations of the above are used in drivers having to deal with this sort of behavior.
-- Dan Smith www.danplanet.com KK7DS
chirp_devel mailing list chirp_devel@intrepid.danplanet.com http://intrepid.danplanet.com/mailman/listinfo/chirp_devel Developer docs: http://chirp.danplanet.com/projects/chirp/wiki/Developers