Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added msg 14 - safety broadcast

git-svn-id: https://cowfish.unh.edu/projects/schwehr/trunk/src/libais@13636 a19cddd1-5311-0410-bb07-9ca93daf0f0b
  • Loading branch information...
commit d85163142a358b3585bce36aa92610d23a36c6b1 1 parent 113e862
schwehr authored
View
9 Makefile
@@ -14,10 +14,12 @@ CXXFLAGS += -Werror
#CFLAGS := ${CXXFLAGS}
-SRCS:= ais.cpp ais123.cpp ais4_11.cpp ais5.cpp ais7_13.cpp
+SRCS := ais.cpp ais123.cpp ais4_11.cpp ais5.cpp ais7_13.cpp
#
-SRCS+= ais18.cpp ais19.cpp
-OBJS:=${SRCS:.cpp=.o}
+SRCS += ais14.cpp
+#
+SRCS += ais18.cpp ais19.cpp
+OBJS := ${SRCS:.cpp=.o}
default:
@echo
@@ -78,6 +80,7 @@ ais123.o: ais.h
ais4_11.o: ais.h
ais5.o: ais.h
ais7_13.o: ais.h
+ais14.o: ais.h
ais18.o: ais.h
ais19.o: ais.h
ais_py.o: ais.h
View
13 ais.h
@@ -183,6 +183,19 @@ class Ais7_13 : public AisMsg {
std::ostream& operator<< (std::ostream& o, Ais7_13 const& msg);
+// Safety broadcast
+class Ais14 : public AisMsg {
+public:
+ int message_id;
+ int repeat_indicator;
+ int mmsi;
+ std::string text;
+ int expected_num_spare_bits; // The bits in the nmea_payload not used
+ Ais14(const char *nmea_payload);
+ void print();
+};
+
+std::ostream& operator<< (std::ostream& o, Ais14 const& msg);
// B - Class B position report
class Ais18 : public AisMsg {
View
45 ais14.cpp
@@ -0,0 +1,45 @@
+// Since 2010-May-5
+// Safety related broadcast message (SRBM)
+#include "ais.h"
+
+Ais14::Ais14
+(const char *nmea_payload) {
+ assert(nmea_payload);
+ init();
+
+ const int num_bits = strlen(nmea_payload)*6;
+ if (num_bits < 46 or num_bits > 1008) {
+ // FIX: can't check to make sure the string occurs on 6-bit boundaries
+ // Need to know the spare bits
+ status = AIS_ERR_BAD_BIT_COUNT;
+ std::cout << "num_bits: " << num_bits << "\n";
+ return;
+ }
+
+ std::bitset<1008> bs; // 424 + 2 spare bits => 71 characters
+ status = aivdm_to_bits(bs, nmea_payload);
+ if (had_error()) {
+ std::cout << "bit convert failed" << std::endl;
+ return;
+ }
+
+ message_id = ubits(bs, 0, 6);
+ if (14 != message_id) {
+ std::cout << "bad id: " << message_id << "\n";
+ status = AIS_ERR_WRONG_MSG_TYPE; return;
+ }
+ repeat_indicator = ubits(bs,6,2);
+ mmsi = ubits(bs,8,30);
+
+ const int num_char = ( num_bits - 40 ) / 6;
+
+ text = ais_str(bs, 40, num_char * 6);
+ expected_num_spare_bits = num_bits - 40 - num_char*60; // Can use this to check later
+}
+
+void
+Ais14::print() {
+ std::cout << "Ais14 - Safety broadcast\n"
+ << "\tmessage_id: " << message_id << " " << repeat_indicator << " " << mmsi << "\n"
+ << "\ttext: " << text << "\n";
+}
View
3  ais5.cpp
@@ -1,10 +1,11 @@
// Since Apr 2010
+// Class A shipdata
#include "ais.h"
//#include <iostream>
//#include <bitset>
//#include <string>
-#include <cassert>
+//#include <cassert>
//#include <cmath>
View
2  ais_py.cpp
@@ -264,7 +264,7 @@ decode(PyObject *self, PyObject *args) {
// 13 - See 7
- // 14 - SRBM
+ // 14 - SRBM - Safety broadcast
case '>':
// result = ais14_to_pydict(nmea_payload);
PyErr_Format(ais_py_exception, "ais.decode: message 14 (>) not yet handled");
View
28 test_libais.cpp
@@ -50,6 +50,32 @@ int main(UNUSED char *argc, UNUSED char* argv[]) {
}
#endif
+
+ //////////////////////////////////////////////////////////////////////
+ // 14 - Safety Broadcast
+ //////////////////////////////////////////////////////////////////////
+
+ if (true) {
+ // From GPSD - !AIVDM,1,1,,A,>5?Per18=HB1U:1@E=B0m<L,2*51
+ {
+ Ais14 msg(">5?Per18=HB1U:1@E=B0m<L");
+ if (!msg.had_error()) msg.print(); else std::cout<<"FAILED 14 1\n";
+ std::cout << "\n";
+ }
+ // From GPSD - !AIVDM,1,1,,A,>3R1p10E3;;R0USCR0HO>0@gN10kGJp,2*7F
+ {
+ Ais14 msg(">3R1p10E3;;R0USCR0HO>0@gN10kGJp");
+ if (!msg.had_error()) msg.print(); else std::cout<<"FAILED\n";
+ std::cout << "\n";
+ }
+ // From GPSD - !AIVDM,1,1,,A,>4aDT81@E=@,2*2E
+ {
+ Ais14 msg(">4aDT81@E=@");
+ if (!msg.had_error()) msg.print(); else std::cout<<"FAILED\n";
+ std::cout << "\n";
+ }
+ }
+
//////////////////////////////////////////////////////////////////////
// 18 - Class B
//////////////////////////////////////////////////////////////////////
@@ -78,7 +104,7 @@ int main(UNUSED char *argc, UNUSED char* argv[]) {
// 19 - Class B equip pos report
//////////////////////////////////////////////////////////////////////
- if (true) {
+ if (false) {
// !AIVDM,1,1,,B,C5N3SRP0IFJKmE4:v6pBGw`@62PaLELTBJ:V00000000S0D:R220,0*3A,b003669952,1272415462
{
Ais19 msg("C5N3SRP0IFJKmE4:v6pBGw`@62PaLELTBJ:V00000000S0D:R220");
Please sign in to comment.
Something went wrong with that request. Please try again.