Author Topic: Pulling data from AIS transponder via USB  (Read 601 times)

sfainfiser

  • Member
  • ***
  • Posts: 2
Pulling data from AIS transponder via USB
« on: October 22, 2019, 10:51:39 pm »
Hi there,

I'm a software developer - but totally new to hardware / USB.

I've got a couple of personal projects that I'm starting, and the first is to pull AIS (ship / vessel) data from a transponder(Correction: It's an antenna + receiver, not a transponder ). On my Mac, I have an app called NavLink, and the app will pull the data in through the transponder and use it to display ships on the screen.



Also, using Wireshark, I can see the bulk transfers (IN) taking place, and I can see examples like the following data in the "leftover capture data":

!AIVDM,1,1,,B,15N8w<PP0Gqfw<PGuFaquOwJ2@Jf,0*5A

This is the data I'm expecting and can parse.

Connecting to the same transponder to my Raspberry Pi, I'm trying to pull this same data with LIBUSB (Ruby implementation). I'm finding the device and running transfers, but the data I get back seems empty. I'm trying to diagnose where I'm going wrong, and I'm wondering if I'm not setting something up properly before running the transfer.

Code looks like this:

Code: [Select]
require 'libusb'

usb = LIBUSB::Context.new
device = usb.devices( ... ).first    # Uses IDs I don't have handy to find the device
endpoint = device.endpoints.first    # Bulk (IN)

while true
  device.open_interface(0) do |handle|
    # I tried a lot of values for dataIn - not sure what it should be
    # From the docs:
    # :dataIn (Fixnum) the number of bytes expected to receive with an ingoing transfer
    result = handle.bulk_transfer({ endpoint: endpoint, dataIn: 1000 })
    print result
  end
end

This is giving me long strings of \x00\x00\x00 ... with a few \x01b mixed in. This is just empty bytes as far as I can tell. Coming from web development, this is a little lower level than I'm used to.

Just wanted to see if anyone spots anything obvious that I'm doing wrong.

Thanks!
« Last Edit: October 23, 2019, 12:47:48 pm by sfainfiser »

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 2930
    • Lakeview Research
Re: Pulling data from AIS transponder via USB
« Reply #1 on: October 23, 2019, 03:38:19 pm »
On the working system, following enumeration, are there communications that precede collecting the ship data? For example, data for configuration or other tasks? This could use any endpoint(s). If so, you would need to find documentation or reverse-engineer the protocols.

sfainfiser

  • Member
  • ***
  • Posts: 2
Re: Pulling data from AIS transponder via USB
« Reply #2 on: October 23, 2019, 03:43:03 pm »
Ahh okay. I thought there might be some setup that I was missing. I'll see what I can deduce. I don't have access to any documentation, so it will have to be the reverse engineering route.

Thank you!