Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 351 lines (286 sloc) 13.453 kb
3f6276f simple c++ program to excecise the interface
schwehr authored
1 #include "ais.h"
2
62f9951 class B message 18/B looks to be working
schwehr authored
3 //using namespace std;
5545183 error handling now in place. starting on classb
schwehr authored
4
3f6276f simple c++ program to excecise the interface
schwehr authored
5 #define UNUSED __attribute((__unused__))
6
7601f5d close to have the memory leak plugged
schwehr authored
7 int main(UNUSED int argc, UNUSED char* argv[]) {
3f6276f simple c++ program to excecise the interface
schwehr authored
8 build_nmea_lookup();
5545183 error handling now in place. starting on classb
schwehr authored
9
9b5dab1 working on 366_34
schwehr authored
10 //CHECKPOINT;
11
5545183 error handling now in place. starting on classb
schwehr authored
12 ////////////////////////////////////////
13 // 1
14 ////////////////////////////////////////
15
62f9951 class B message 18/B looks to be working
schwehr authored
16 if (false) {
5545183 error handling now in place. starting on classb
schwehr authored
17 // !AIVDM,1,1,,B,15Mq4J0P01EREODRv4@74gv00HRq,0*72,b003669970,1272412824
18 Ais1_2_3("15Mq4J0P01EREODRv4@74gv00HRq");
19 // !AIVDM,1,1,,B,1EN2?oWP00ER5SLRvNPi9gwl0000,0*51,b003669970,1272412824
20 Ais1_2_3("");
21 // !AIVDM,1,1,,B,15N3QPPP0dI?uu>@smtj8wv028Rs,0*23,b003669977,1272412827
22 Ais1_2_3("");
23 // !AIVDM,1,1,,B,15N3J`P01tqr<CDJlP1DKSUn0<04,0*43,b003665001,1272412825
24 Ais1_2_3("15N3J`P01tqr<CDJlP1DKSUn0<04");
25
26 // Bad sized packets
27 Ais1_2_3("15N3J`P01tqr<CDJlP1DKSUn0<0400000"); // too large
28 Ais1_2_3("15N3J`P01tqr<CDJlP1DKSUn"); // too small
29 Ais1_2_3("95N3J`P01tqr<CDJlP1DKSUn0<04"); // wrong message type in the 1st char
30 std::cout << "Expecting bad characters 'zXYZ[\\]^_'" << std::endl;
31 Ais1_2_3("1zXYZ[\\]^_tr<CDJlP1DKSUn0<04"); // invalid character
32
33 }
34
35 ////////////////////////////////////////
36 // 7 and 13
37 ////////////////////////////////////////
03e7b50 bit more work
schwehr authored
38
0d187b2 ais msg 9 - sar position
schwehr authored
39 if (false) {
03e7b50 bit more work
schwehr authored
40 // Causes bus error
41 // !AIVDM,1,1,,A,74i:pT000000,0*52,b003669977,1273190417
42 CHECKPOINT;
43 {Ais7_13 msg("74i:pT000000"); msg.print();}
44 CHECKPOINT;
45
62f9951 class B message 18/B looks to be working
schwehr authored
46 {Ais7_13 msg("75Mu6d0P17IP?PfGSC29WOvb0<14"); msg.print();}
47
5545183 error handling now in place. starting on classb
schwehr authored
48 CHECKPOINT;
62f9951 class B message 18/B looks to be working
schwehr authored
49 { Ais7_13 msg("74eGSe@0owtf"); msg.print(); }
50
5545183 error handling now in place. starting on classb
schwehr authored
51 CHECKPOINT;
62f9951 class B message 18/B looks to be working
schwehr authored
52 {
53 Ais7_13 msg("74eGSe@0owt");
54 assert(msg.had_error());
55 std::cout << "expect error " << AIS_ERR_BAD_BIT_COUNT << ": " << msg.get_error() << std::endl;
56 //msg.print();
57 }
5545183 error handling now in place. starting on classb
schwehr authored
58 }
62f9951 class B message 18/B looks to be working
schwehr authored
59
d851631 added msg 14 - safety broadcast
schwehr authored
60
61 //////////////////////////////////////////////////////////////////////
9a2558c starting on message 8s
schwehr authored
62 // 8 - BBM
63 //////////////////////////////////////////////////////////////////////
64
56b1a5c msg 8 1:11 imo/met hydro
schwehr authored
65 if (false) {
66 int i=0;
67 {
68 // !AIVDM,1,1,8,A,852HH<h0BjMv0=v6kWW<0Pb5<0A8h4=:0010000000000000000002>003P,2*09,1269959103.21
69 Ais8 msg("852HH<h0BjMv0=v6kWW<0Pb5<0A8h4=:0010000000000000000002>003P"); i++;
70 if (!msg.had_error()) msg.print();
71 else std::cout<<"FAILED 8 "<< i << " "<< AIS_STATUS_STRINGS[msg.get_error()] << "\n";
72 std::cout << "\n";
73 }
74
75 }
76
77 ///// 1 11 IMO Met Hydro
9b5dab1 working on 366_34
schwehr authored
78
79 if (false) {
80 CHECKPOINT;
9a2558c starting on message 8s
schwehr authored
81 int i=0;
56b1a5c msg 8 1:11 imo/met hydro
schwehr authored
82 // !AIVDM,1,1,8,A,852HH<h0BjMv0=v6kWW<0Pb5<0A8h4=:0010000000000000000002>003P,2*09,1269959103.21
9a2558c starting on message 8s
schwehr authored
83 {
56b1a5c msg 8 1:11 imo/met hydro
schwehr authored
84 Ais8_1_11 msg("852HH<h0BjMv0=v6kWW<0Pb5<0A8h4=:0010000000000000000002>003P"); i++;
9a2558c starting on message 8s
schwehr authored
85 if (!msg.had_error()) msg.print();
86 else std::cout<<"FAILED 8 "<< i << " "<< AIS_STATUS_STRINGS[msg.get_error()] << "\n";
87 std::cout << "\n";
88 }
9b5dab1 working on 366_34
schwehr authored
89 CHECKPOINT;
90
91 }
92
93 ///// 366 34 - Old Zone Messages - Used up to Summer 2010 in Boston
94 // http://schwehr.org/blog/archives/2009-10.html#e2009-10-15T16_52_31.txt
95 if (false) {
96 CHECKPOINT;
97 int i=0;
98 // Whales observed: !AIVDM,1,1,,B,803OvriK`R0FaqT6gOv763PKLT;0,0*25,d-089,S0392,t204010.00,T10.45701635,r003669945,1255466410,cornell,1255466411.9
99 {
100 Ais8_366_34 msg("803OvriK`R0FaqT6gOv763PKLT;0"); i++;
101 if (!msg.had_error()) msg.print();
102 else std::cout<<"FAILED 8 "<< i << " "<< AIS_STATUS_STRINGS[msg.get_error()] << "\n";
103 std::cout << "\n";
104 }
105 CHECKPOINT;
9a2558c starting on message 8s
schwehr authored
106
107 }
56b1a5c msg 8 1:11 imo/met hydro
schwehr authored
108
9b5dab1 working on 366_34
schwehr authored
109
9a2558c starting on message 8s
schwehr authored
110 //////////////////////////////////////////////////////////////////////
0d187b2 ais msg 9 - sar position
schwehr authored
111 // 9 - Search and rescue
112 //////////////////////////////////////////////////////////////////////
113
72fe7de adding more messages
schwehr authored
114 if (false) {
0d187b2 ais msg 9 - sar position
schwehr authored
115 int i=0;
116 // !AIVDM,1,1,,B,9002=mQq1oIJvt6;2eUn>Sh0040<,0*5D,b003669979,1273709011
117 {
118 Ais9 msg("9002=mQq1oIJvt6;2eUn>Sh0040<"); i++;
119 if (!msg.had_error()) msg.print();
72fe7de adding more messages
schwehr authored
120 else std::cout<<"FAILED 9 "<< i << " "<< AIS_STATUS_STRINGS[msg.get_error()] << "\n";
0d187b2 ais msg 9 - sar position
schwehr authored
121 std::cout << "\n";
122 }
123 // !AIVDM,1,1,,A,9002=mQrAgIK1cd;1m`F@0@00<3w,0*45,b2003669980,1273709054
124 {
125 Ais9 msg("9002=mQrAgIK1cd;1m`F@0@00<3w"); i++;
126 if (!msg.had_error()) msg.print();
72fe7de adding more messages
schwehr authored
127 else std::cout<<"FAILED 9 "<< i << " "<< AIS_STATUS_STRINGS[msg.get_error()] << "\n";
128 std::cout << "\n";
129 }
130 }
131
132
133 //////////////////////////////////////////////////////////////////////
134 // 10 - ":" UTC and date inquery
135 //////////////////////////////////////////////////////////////////////
136
137 if (false) {
138 int i=0;
139 // !AIVDM,1,1,,B,:5CoIn0kwN0P,0*23,b003669708,1273711619
140 {
141 Ais10 msg(":5CoIn0kwN0P"); i++;
142 if (!msg.had_error()) msg.print();
143 else std::cout<<"FAILED 10 "<< i << " "<< AIS_STATUS_STRINGS[msg.get_error()] << "\n";
144 std::cout << "\n";
145 }
146 // !AIVDM,1,1,,B,:3PTOn1ifeq0,0*13,d-096,S0215,t005405.00,T05.73646837,r11NTRQ1,1273712049
147 {
148 Ais10 msg(":3PTOn1ifeq0"); i++;
149 if (!msg.had_error()) msg.print();
150 else std::cout<<"FAILED 10 "<< i << " "<< AIS_STATUS_STRINGS[msg.get_error()] << "\n";
151 std::cout << "\n";
152 }
153 }
154
155 //////////////////////////////////////////////////////////////////////
156 // 11 - "" UTC/date response - same as 4
157 //////////////////////////////////////////////////////////////////////
158
159 if (false) {
160 int i=0;
161 // AIVDM,1,1,,A,;4eG>3iuaFP2:r3OiBH7;8i00000,0*65,d-104,S0420,t000211.00,T11.21643139,r09STOL1,1273708934
162 {
163 Ais4_11 msg(";4eG>3iuaFP2:r3OiBH7;8i00000"); i++;
164 if (!msg.had_error()) msg.print();
165 else std::cout<<"FAILED 11 "<< i << " "<< AIS_STATUS_STRINGS[msg.get_error()] << "\n";
166 std::cout << "\n";
167 }
168 }
169
170 //////////////////////////////////////////////////////////////////////
171 // 12 - "<" Addressed Safety message
172 //////////////////////////////////////////////////////////////////////
173
174 if (false) {
175 int i=0;
176 // !AIVDM,1,1,,A,<02:oP0kKcv0@<51C5PB5@?BDPD?P:?2?EB7PDB16693P381>>5<PikP,0*37
177 // From AISHUB via GPSD
178 {
179 Ais12 msg("<02:oP0kKcv0@<51C5PB5@?BDPD?P:?2?EB7PDB16693P381>>5<PikP"); i++;
180 if (!msg.had_error()) msg.print();
181 else std::cout<<"FAILED 12 "<< i << " "<< AIS_STATUS_STRINGS[msg.get_error()] << "\n";
182 std::cout << "\n";
183 }
184 // !AIVDM,1,1,,B,<3@oGf0kErm0G81Dw0,4*5C,d-115,S9999,r003669930,1273716298
185 {
186 Ais12 msg("<3@oGf0kErm0G81Dw0"); i++;
187 if (!msg.had_error()) msg.print();
188 else std::cout<<"FAILED 12 "<< i << " "<< AIS_STATUS_STRINGS[msg.get_error()] << "\n";
0d187b2 ais msg 9 - sar position
schwehr authored
189 std::cout << "\n";
190 }
191 }
192
72fe7de adding more messages
schwehr authored
193
194
0d187b2 ais msg 9 - sar position
schwehr authored
195 //////////////////////////////////////////////////////////////////////
d851631 added msg 14 - safety broadcast
schwehr authored
196 // 14 - Safety Broadcast
197 //////////////////////////////////////////////////////////////////////
198
fa39f6c Message 24 now included
schwehr authored
199 if (false) {
d851631 added msg 14 - safety broadcast
schwehr authored
200 // From GPSD - !AIVDM,1,1,,A,>5?Per18=HB1U:1@E=B0m<L,2*51
201 {
202 Ais14 msg(">5?Per18=HB1U:1@E=B0m<L");
203 if (!msg.had_error()) msg.print(); else std::cout<<"FAILED 14 1\n";
204 std::cout << "\n";
205 }
206 // From GPSD - !AIVDM,1,1,,A,>3R1p10E3;;R0USCR0HO>0@gN10kGJp,2*7F
207 {
208 Ais14 msg(">3R1p10E3;;R0USCR0HO>0@gN10kGJp");
209 if (!msg.had_error()) msg.print(); else std::cout<<"FAILED\n";
210 std::cout << "\n";
211 }
212 // From GPSD - !AIVDM,1,1,,A,>4aDT81@E=@,2*2E
213 {
214 Ais14 msg(">4aDT81@E=@");
215 if (!msg.had_error()) msg.print(); else std::cout<<"FAILED\n";
216 std::cout << "\n";
217 }
218 }
219
62f9951 class B message 18/B looks to be working
schwehr authored
220 //////////////////////////////////////////////////////////////////////
72fe7de adding more messages
schwehr authored
221 // 15 - ? Interrogation
222 //////////////////////////////////////////////////////////////////////
223
224 if (false) {
120c0e2 need many more docs
schwehr authored
225 int i=0;
72fe7de adding more messages
schwehr authored
226 // From GPSD - !AIVDM,1,1,,A,?5OP=l00052HD00,2*5B
227 {
120c0e2 need many more docs
schwehr authored
228 Ais15 msg("?5OP=l00052HD00"); i++;
72fe7de adding more messages
schwehr authored
229 if (!msg.had_error()) msg.print(); else std::cout<<"FAILED 15 "<< i << " "<< AIS_STATUS_STRINGS[msg.get_error()] << "\n";
230 std::cout << "\n";
231 }
232 // !AIVDM,1,1,,B,?h3Owpi;EluT000,2*61,b003669703,1273708908
233 {
120c0e2 need many more docs
schwehr authored
234 Ais15 msg("?h3Owpi;EluT000"); i++;
72fe7de adding more messages
schwehr authored
235 if (!msg.had_error()) msg.print(); else std::cout<<"FAILED 15 "<< i << " "<< AIS_STATUS_STRINGS[msg.get_error()] << "\n";
236 std::cout << "\n";
237 }
238 //!AIVDM,1,1,,B,?h3Ovn1GP<K0<P@59a0,2*04,d-077,S1832,t004248.00,T48.85520485,r07RPAL1,1272415370
239 {
120c0e2 need many more docs
schwehr authored
240 Ais15 msg("?h3Ovn1GP<K0<P@59a0"); i++;
72fe7de adding more messages
schwehr authored
241 if (!msg.had_error()) msg.print(); else std::cout<<"FAILED 15 "<< i << " "<< AIS_STATUS_STRINGS[msg.get_error()] << "\n";
242 std::cout << "\n";
243 }
120c0e2 need many more docs
schwehr authored
244 }
72fe7de adding more messages
schwehr authored
245
0150190 more header definitions for AIS major messages
schwehr authored
246 // !AIVDM,1,1,,B,@h3OwhiGOl583h0000000500,0*30,b003669956,1272442253
247
248
72fe7de adding more messages
schwehr authored
249 //////////////////////////////////////////////////////////////////////
62f9951 class B message 18/B looks to be working
schwehr authored
250 // 18 - Class B
251 //////////////////////////////////////////////////////////////////////
252
113e862 Add message 19
schwehr authored
253 if (false) {
62f9951 class B message 18/B looks to be working
schwehr authored
254 // !AIVDM,1,1,,A,B5N3SRP0FFJFC`4:CQDFKwiP200>,0*75,b003669952,1272413103
255 { Ais18 msg("B5N3SRP0FFJFC`4:CQDFKwiP200>"); msg.print(); std::cout << std::endl; }
256 // !AIVDM,1,1,,B,B5NGjdP03MkEvV6vJTN`SwuUoP06,0*08,b003669703,1272412832
257 { Ais18 msg("B5NGjdP03MkEvV6vJTN`SwuUoP06"); msg.print(); std::cout << std::endl; }
258 // !AIVDM,1,1,,B,BU2K5MP005kN8WVSrcP03wb5oP00,0*44,d-077,S0791,t000021.00,T21.09527304,r13SCDS1,1272412822
259 { Ais18 msg("B5MtL4P00FK?Pa4I98`G`uS0200>"); msg.print(); std::cout << std::endl; }
260 // !AIVDM,1,1,,B,B5MtL4P00FK?Pa4I98`G`uS0200>,0*61,d-079,S0269,t000007.00,T07.17528574,r08RROB1,1272412808
261 { Ais18 msg(""); msg.print(); }
262
263
264 // !AIVDM,1,1,,B,Bov9gKvWbf;juI`NN@CeG1DF;3Gs,0*6D,d-126,S2121,t101756.00,T56.56587008,r09SMRQ1,1272449876
265 { Ais18 msg("Bov9gKvWbf;juI`NN@CeG1DF;3Gs"); msg.print(); std::cout << std::endl; }
266 // !AIVDM,1,1,,B,B@MMSv=E@JJd``ksAupQpveN`VH?,0*3F,d-126,S1407,t130537.00,T37.53680769,r09SSAG1,1272459940
267 { Ais18 msg("B@MMSv=E@JJd``ksAupQpveN`VH?"); msg.print(); std::cout << std::endl; }
268
269 }
113e862 Add message 19
schwehr authored
270
271
272
273 //////////////////////////////////////////////////////////////////////
274 // 19 - Class B equip pos report
275 //////////////////////////////////////////////////////////////////////
276
d851631 added msg 14 - safety broadcast
schwehr authored
277 if (false) {
113e862 Add message 19
schwehr authored
278 // !AIVDM,1,1,,B,C5N3SRP0IFJKmE4:v6pBGw`@62PaLELTBJ:V00000000S0D:R220,0*3A,b003669952,1272415462
279 {
280 Ais19 msg("C5N3SRP0IFJKmE4:v6pBGw`@62PaLELTBJ:V00000000S0D:R220");
281 if (!msg.had_error()) msg.print(); else std::cout<<"FAILED\n";
282 std::cout << "\n";
283 }
284
285 // !AIVDM,1,1,2,B,C5MtL4al06K?Pa4I99@G`us>@2fF0000000000000000?P000020,0*73,d-080,S2043,t013454.00,T54.48188603,r08RROB1,1272418496
286 {
287 Ais19 msg("C5MtL4al06K?Pa4I99@G`us>@2fF0000000000000000?P000020");
288 if (!msg.had_error()) msg.print(); else std::cout<<"FAILED\n";
289 std::cout << "\n";
290 }
291
292 }
fa39f6c Message 24 now included
schwehr authored
293
9b5dab1 working on 366_34
schwehr authored
294
295 //////////////////////////////////////////////////////////////////////
296 // 21 - ATON status report
297 //////////////////////////////////////////////////////////////////////
298
299 if (true) {
300 //CHECKPOINT;
301 int i=0;
302 // From OHMEX test at CCOM
303 // !AIVDM,1,1,,A,E52HH<h:W4?Sa2Pb?Q0dgVPa4W0uM`P9<EmvH00000u@20,4*15,1269957000.16
304 if (false) {
305 CHECKPOINT;
306 Ais21 msg("E52HH<h:W4?Sa2Pb?Q0dgVPa4W0uM`P9<EmvH00000u@20"); i++;
307 if (!msg.had_error()) msg.print(); else std::cout<<"FAILED 21 "<< i << " "<< AIS_STATUS_STRINGS[msg.get_error()] << "\n";
308 std::cout << "\n";
309 }
310
311 //!AIVDM,2,1,5,B,E1mg=5J1T4W0h97aRh6ba84<h2d;W:Te=eLvH50```q,0*46
312 //!AIVDM,2,2,5,B,:D44QDlp0C1DU00,2*36
313 // Becomes !AIVDM,1,1,5,B,E1mg=5J1T4W0h97aRh6ba84<h2d;W:Te=eLvH50```q:D44QDlp0C1DU00,2*63
314 {
315 Ais21 msg("E1mg=5J1T4W0h97aRh6ba84<h2d;W:Te=eLvH50```q:D44QDlp0C1DU00"); i++;
316 if (!msg.had_error()) msg.print(); else std::cout<<"FAILED 21 "<< i << " "<< AIS_STATUS_STRINGS[msg.get_error()] << "\n";
317 std::cout << "\n";
318 }
319
320 }
321
322
fa39f6c Message 24 now included
schwehr authored
323 //////////////////////////////////////////////////////////////////////
324 // 24 - Class B static data msgs A and B
325 //////////////////////////////////////////////////////////////////////
326
72fe7de adding more messages
schwehr authored
327 if (false) {
fa39f6c Message 24 now included
schwehr authored
328 // !AIVDM,1,1,,B,H5NHcTP<51@4TrM>10584@U<D00,2*77,x337805,b003669710,1241895000
329 {
330 Ais24 msg("H5NHcTP<51@4TrM>10584@U<D00");
331 if (!msg.had_error()) msg.print(); else std::cout<<"FAILED\n";
332 std::cout << "\n";
333 }
334 // !AIVDM,1,1,,B,HU2K5NTn13BijklG44oppk103210,0*06,s23294,d-114,T44.21624911,x731910,r13RSMT1,1241894986
335 {
336 Ais24 msg("HU2K5NTn13BijklG44oppk103210");
337 if (!msg.had_error()) msg.print(); else std::cout<<"FAILED\n";
338 std::cout << "\n";
339 }
340
341
342 }
343
62f9951 class B message 18/B looks to be working
schwehr authored
344 //////////////////////////////
345 // DONE
346 //////////////////////////////
347
3f6276f simple c++ program to excecise the interface
schwehr authored
348 return 0;
62f9951 class B message 18/B looks to be working
schwehr authored
349
3f6276f simple c++ program to excecise the interface
schwehr authored
350 }
Something went wrong with that request. Please try again.