Using a USB-UIRT device I am able to receive the pulses coming from the gun. The signal starts with a pulse of ~6700 (sometimes higher, sometimes lower). Followed by 32 interleaved pulses and spaces that hover around 700. The spaces and pulses are effectively 64 'bits' although it seems only the spaces are actually used, not the pulses as I previously thought. The output clearly spaces, but because that made no sense to my brain, so I said pulses in previous posts. Anyway the way I'm tracking it, I'm counting the spaces and pulses just in case I get a surprise somewhere. The spaces that have meaning hover around 3200. So in my code I just look for greater than 5000 for the 'frame start' and greater than 2000 for the 'space' to be a high bit. Keep in mind I'm counting pulses and spaces when tracking them and I start at zero (because it's not confusing enough right?), so if I say bit 4, I mean space(0), pulse(1), space(2),pulse(3),space(4). If you don't like it, divide them by 2 to get the 'space' position only (which is why I started with zero). So far here are the bits of note:
BIT 10 - always high in the two assault strikers I've tested: G.A.R.-023 and D.C.R.-012
BIT 12 - part of the team color
BIT 14 - part of the team color
12 and 14 high = blue
12 and 14 low = red
12 low and 14 high = yellow
12 high and 14 low = green
With this info, I can now determine what color shot the IR sensor and can effectively write my own target for capture the flag.
But wait theirs more! For shots:
bit 40, bit 42, bit 44, bit 46, bit 50, bit 56, bit 58, bit 60, bit 62.
High bits for Laser strike: 42, 46, 60
High bits for Stealth strike: 42, 44, 60
High bits for Pulse strike: 42, 44, 46, 60, 62
High bits for Rail strike: 40, 58, 60
High bits for Sonic strike: 40, 46, 56
So there is rather some reserve bits in the middle or the assault strikers add ons use the middle bits in the low 50's. If you read the bits from right to left starting at 40 and ending at 62, you have a 12-bit number that gets bigger the more powerful the strike. I vaguely recall 12-bits being important in the IR remote space, so maybe that's why. Maybe my math is off too. Anyway, if you take my 12 bits as binary numbers:
Laser - 1344
Stealth - 1538
Pulse - 1795
Rail - 2054
Sonic - 2312
Stealth strike may be an outlier, because I'm not sure that it's stronger than a laser strike in terms of damage done to the other guns. Anyway, since I can decode strike values, and I have orders of magnitude, I can do some fun stuff with my computer based target. For example, I can have degrees of team color. You could have a laser strike be +1, stealth +2, etc. And every time you shoot my target, the counter goes up (or the team color level bar could fill more screen) up to a maximum number, say 5 or 6. Then to recapture the flag, you would have to take away the apposing teams hits first, before you could turn it to your color, making capturing and holding a flag a little more interesting.
I'm still tweaking my perl code, but in short, I went the
route to get the data. The mode2 binary from LIRC does a great job for me already, why re-invent the wheel at this point? I have it capturing the 'high' bits and printing the team color so far.
open(MODE,"mode2 --driver=usb_uirt_raw --device=/dev/ttyUSB0|") || die "Unable to open mode2\n";
So I'm getting pretty close!
---- SHOT ---- 10 - 3150 12 - 3200 14 - 3150 42 - 3150 44 - 3200 60 - 3200 ---- SHOT ---- COLOR: blue ---- SHOT ---- 10 - 3200 12 - 3200 14 - 3200 42 - 3200 44 - 3200 60 - 3200 ---- SHOT ---- COLOR: blue ---- SHOT ---- 10 - 3150 42 - 3200 44 - 3200 60 - 3150 ---- SHOT ---- COLOR: red ---- SHOT ---- 10 - 3200 42 - 3150 44 - 3150 60 - 3200 ---- SHOT ---- COLOR: red ---- SHOT ----
No comments:
Post a Comment