Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 53 lines (42 sloc) 1.515 kb
ac15f1d The ack message... helped me find a problem in noaadata. Nice!
schwehr authored
1 #include "ais.h"
2
3 #include <iostream>
4 #include <bitset>
5 //#include <string>
6 #include <cassert>
7 //#include <vector>
8 using namespace std;
9
10 Ais7_13::Ais7_13(const char *nmea_payload) {
11 assert (nmea_payload);
12 const size_t num_bits = strlen(nmea_payload) * 6;
13 cout << "num_bits: " << num_bits << endl;
14
15 assert ( (40+32*1)==num_bits or (40+32*2)==num_bits or (40+32*3)==num_bits or (40+32*4) == num_bits);
16
17 std::bitset<168> bs;
18 CHECKPOINT;
19
20 aivdm_to_bits(bs, nmea_payload);
21
22 message_id = ubits(bs, 0, 6);
23 cout << "message_id: " << message_id << endl;
24 assert (message_id == 7 or message_id == 13);
25 repeat_indicator = ubits(bs,6,2);
26 mmsi = ubits(bs,8,30);
27
28 spare = ubits(bs,38,2);
29
30 const size_t num_acks = (num_bits - 40) / 32;
31 for (size_t i=0; i < num_acks; i++) {
32 const size_t start = 40 + i*32;
33 cout << i << ": " << start << endl;
34 const int id = ubits(bs,40+i*32,30);
35 cout << "id: " << id << endl;
36 const int seq = ubits(bs,40+i*32+30,2);
37 dest_mmsi.push_back(id);
38 seq_num.push_back(seq);
39 }
40 }
41
42 void
43 Ais7_13::print() {
44 std::cout << message_id << ( (7==message_id)?" ABM Ack":" safety ack" ) << "\n"
45 << "\tmmsi: " << mmsi << " repeat: " << repeat_indicator << "\n";
46 std::cout << "\tspare: " << spare << "\n";
47 for (size_t i=0; i < dest_mmsi.size(); i++) {
48 std::cout << "\tack: " << dest_mmsi[i] << " seq: " << seq_num[i] << "\n";
49 }
50
51 std::cout << std::endl;
52 }
Something went wrong with that request. Please try again.