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:
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!