On Wed, Aug 19, 2020 at 10:15 AM Charles Plante
<
charlesplan...@gmail.com> wrote:
>
> I got an XP10 dive computer too. Im hoping to make it work with and Arduino IRDA shield. How is Subsurface accessing the serial COM port ?
Right now libdivecompuer marks the XP-10 as IRDA only, so subsurface
wouldn't even try to access it with a serial port.
That said, if you make the Arduino do all the IRDA connection parts,
and the serial port would act as the transport only (ie there would be
no sign of irda as far as libdivecomputer is concerned - it would just
see the raw data as serial), then I think supporting it would be
literally as simple as adding a DC_TRANSPORT_SERIAL flag to the
device, ie something like this in libdivecomputer:
- {"Subgear", "XP-10", DC_FAMILY_UWATEC_SMART,
0x13, DC_TRANSPORT_IRDA, dc_filter_uwatec},
+ {"Subgear", "XP-10", DC_FAMILY_UWATEC_SMART,
0x13, DC_TRANSPORT_IRDA | DC_TRANSPORT_SERIAL, dc_filter_uwatec},
and if you're doing an Arduino shield thing, I'm assuming you're also
able to build libdivecomputer and subsurface with that change?
HOWEVER.
The libdivecomputer packetization is different for serial and IRDA. So
you'd have to not just do the IRDA connection part, you'd have to
re-packetize the IRDA data as "serial packet" data.
The serial packet format on sending is very simple. For one "packet", you'd see:
- 7 bytes of fixed header:
FF FF FF A6 59 BD C2
- 4-byte LE size of data packet (command byte + arguments), and since
the size is limited, it's just
xx 00 00 00
- payload (cmd byte + data bytes)
- one final checksum byte that is just the xor of the 4 bytes of
length and the payload
and when the arduino receives this data, it should just send the
payload as a IRDA COMM packet (which involves whatever IRDA COMM
protocol stuff you need - I don't know what the Arduino IRDA libraries
look like, I assume they have that part).
Going the other way, when you receive an IRDA COMM packet, your
Arduino logic should send it back as
- 4-byte size LE payload size
- payload (cmd byte + data bytes)
- one byte xor checksum of the above.
So it's really the same format going both ways, apart from that extra
7-byte synchronization header that libdivecomputer sends and you
should basically ignore.
NOTE! I have not tried any of the above. This is purely by reading
what libdivecomputer does. I've never used an IRDA dive computer. I'll
be happy to help if you get to the point where you see serial and IRDA
data flowing, though.
Linus