Repository: M0r13n/pyais

Issue:
RAIM field integer in message type 4, otherwise boolean?
I've found in messages of type 4 the RAIM flag is an integer. But for other messages it is a boolean? I'm not sure if this is a bug or by design?

Discussion:

Patch:
diff --git a/pyais/messages.py b/pyais/messages.py
index 07478b9..3cdd34d 100644
--- a/pyais/messages.py
+++ b/pyais/messages.py
@@ -563,7 +563,7 @@ class MessageType4(Payload):
     lat = bit_field(27, int, from_converter=from_lat_lon, to_converter=to_lat_lon, signed=True, default=0)
     epfd = bit_field(4, int, default=0, from_converter=EpfdType.from_value, to_converter=EpfdType.from_value)
     spare = bit_field(10, int, default=0)
-    raim = bit_field(1, int, default=0)
+    raim = bit_field(1, bool, default=0)
     radio = bit_field(19, int, default=0)
 
 
@@ -669,7 +669,7 @@ class MessageType9(Payload):
     dte = bit_field(1, int, default=0)
     spare = bit_field(3, int, default=0)
     assigned = bit_field(1, int, default=0)
-    raim = bit_field(1, int, default=0)
+    raim = bit_field(1, bool, default=0)
     radio = bit_field(20, int, default=0)
 
 
@@ -1297,7 +1297,7 @@ class MessageType27(Payload):
     mmsi = bit_field(30, int, from_converter=from_mmsi, to_converter=to_mmsi)
 
     accuracy = bit_field(1, int, default=0)
-    raim = bit_field(1, int, default=0)
+    raim = bit_field(1, bool, default=0)
     status = bit_field(4, int, default=0, from_converter=NavigationStatus, to_converter=NavigationStatus)
     lon = bit_field(18, int, from_converter=from_lat_lon_600, to_converter=to_lat_lon_600, default=0)
     lat = bit_field(17, int, from_converter=from_lat_lon_600, to_converter=to_lat_lon_600, default=0)


Test patch:
diff --git a/tests/test_decode.py b/tests/test_decode.py
index 8442ca3..c1ac917 100644
--- a/tests/test_decode.py
+++ b/tests/test_decode.py
@@ -101,6 +101,7 @@ class TestAIS(unittest.TestCase):
         assert msg['second'] == 34
         assert msg['maneuver'] == ManeuverIndicator.NotAvailable
         assert msg['raim']
+        assert isinstance(msg['raim'], bool)
 
     def test_msg_type_1_c(self):
         msg = decode(b"!AIVDM,1,1,,B,181:Kjh01ewHFRPDK1s3IRcn06sd,0*08").asdict()
@@ -226,6 +227,7 @@ class TestAIS(unittest.TestCase):
         assert msg['dte'] == 1
         assert msg['radio'] == 33392
         assert not msg['raim']
+        assert isinstance(msg['raim'], bool)
 
     def test_msg_type_10_a(self):
         msg = decode(b"!AIVDM,1,1,,B,:5MlU41GMK6@,0*6C").asdict()
@@ -360,6 +362,7 @@ class TestAIS(unittest.TestCase):
         assert msg['msg22'] == 1
         assert not msg['assigned']
         assert not msg['raim']
+        assert isinstance(msg['raim'], bool)
 
     def test_msg_type_19(self):
         msg = decode(b"!AIVDM,1,1,,B,C5N3SRgPEnJGEBT>NhWAwwo862PaLELTBJ:V00000000S0D:R220,0*0B").asdict()