Repository: M0r13n/pyais

Issue:
in v2-alpha, MessageType21 payload includes shipname, which I think should just be name
In messages.py:

```py
lass MessageType21(Payload):
    """
    Aid-to-Navigation Report
    Src: https://gpsd.gitlab.io/gpsd/AIVDM.html#_type_21_aid_to_navigation_report
    """
....
    shipname = bit_field(120, str, default='')
```

I believe `shipname` should simply be `name`, which is what's listed in that [gitlab URL](https://gpsd.gitlab.io/gpsd/AIVDM.html#_type_21_aid_to_navigation_report). 

I found this when testing a script I use which displays ship names my receiver is picking up. With ~v1.7 I would get only the shipnames, but with v2 in addition to ships I'd get A, B, C, 1, 2, etc., which are aids to navigation markers from type 21 messages. 

Discussion:

Patch:
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index 867ea54..4272b0e 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -1,6 +1,12 @@
 ====================
  pyais CHANGELOG
 ====================
+-------------------------------------------------------------------------------
+ Version 2.0.1  6 Feb 2022
+-------------------------------------------------------------------------------
+* Closes https://github.com/M0r13n/pyais/issues/52
+  * renames shipname to name for type 21
+
 -------------------------------------------------------------------------------
  Version 2.0.0-alpha  6 Feb 2022
 -------------------------------------------------------------------------------
diff --git a/docs/messages.rst b/docs/messages.rst
index 5d1907a..5bc0787 100644
--- a/docs/messages.rst
+++ b/docs/messages.rst
@@ -1397,7 +1397,7 @@ MessageType21
             * type: <class 'int'>
             * bit-width: 5
             * default: 0
-        * `shipname`
+        * `name`
             * type: <class 'str'>
             * bit-width: 120
             * default:
diff --git a/pyais/__init__.py b/pyais/__init__.py
index d73ad6e..98652c3 100644
--- a/pyais/__init__.py
+++ b/pyais/__init__.py
@@ -4,7 +4,7 @@ from pyais.encode import encode_dict, encode_msg, ais_to_nmea_0183
 from pyais.decode import decode
 
 __license__ = 'MIT'
-__version__ = '2.0.0'
+__version__ = '2.0.1'
 __author__ = 'Leon Morten Richter'
 
 __all__ = (
diff --git a/pyais/messages.py b/pyais/messages.py
index 7745705..07478b9 100644
--- a/pyais/messages.py
+++ b/pyais/messages.py
@@ -892,7 +892,7 @@ class MessageType21(Payload):
     mmsi = bit_field(30, int, from_converter=from_mmsi, to_converter=to_mmsi)
 
     aid_type = bit_field(5, int, default=0, from_converter=NavAid.from_value, to_converter=NavAid.from_value)
-    shipname = bit_field(120, str, default='')
+    name = bit_field(120, str, default='')
     accuracy = bit_field(1, bool, default=0)
     lon = bit_field(28, int, from_converter=from_lat_lon, to_converter=to_lat_lon, signed=True, default=0)
     lat = bit_field(27, int, from_converter=from_lat_lon, to_converter=to_lat_lon, signed=True, default=0)


Test patch:
diff --git a/tests/test_decode.py b/tests/test_decode.py
index 03ab5ac..8442ca3 100644
--- a/tests/test_decode.py
+++ b/tests/test_decode.py
@@ -405,7 +405,7 @@ class TestAIS(unittest.TestCase):
         assert msg['msg_type'] == 21
         assert msg['mmsi'] == "316021442"
         assert msg['aid_type'] == NavAid.REFERENCE_POINT
-        assert msg['shipname'] == "DFO2"
+        assert msg['name'] == "DFO2"
         assert msg['accuracy'] == 1
         assert msg['lat'] == 48.65457
         assert msg['lon'] == -123.429155
@@ -662,7 +662,7 @@ class TestAIS(unittest.TestCase):
         self.assertEqual(decoded.repeat, 0)
         self.assertEqual(decoded.mmsi, '995126020')
         self.assertEqual(decoded.aid_type, NavAid.ISOLATED_DANGER)
-        self.assertEqual(decoded.shipname, 'SIMPSON ROCK')
+        self.assertEqual(decoded.name, 'SIMPSON ROCK')
         self.assertEqual(decoded.accuracy, True)
         self.assertEqual(decoded.lon, 175.119987)
         self.assertEqual(decoded.lat, -36.0075)
@@ -689,7 +689,7 @@ class TestAIS(unittest.TestCase):
         self.assertEqual(decoded.repeat, 0)
         self.assertEqual(decoded.mmsi, '995036013')
         self.assertEqual(decoded.aid_type, NavAid.STARBOARD_HAND_MARK)
-        self.assertEqual(decoded.shipname, 'STDB CUT 2')
+        self.assertEqual(decoded.name, 'STDB CUT 2')
         self.assertEqual(decoded.accuracy, True)
         self.assertEqual(decoded.lon, 115.691833)
         self.assertEqual(decoded.lat, -32.004333)
@@ -748,7 +748,7 @@ class TestAIS(unittest.TestCase):
                 'regional': 4,
                 'repeat': 0,
                 'second': 60,
-                'shipname': 'STDB CUT 2',
+                'name': 'STDB CUT 2',
                 'spare': None,
                 'to_bow': 0,
                 'to_port': 0,
@@ -787,7 +787,7 @@ class TestAIS(unittest.TestCase):
                 'repeat': 0,
                 'second': 60,
                 'seq_id': None,
-                'shipname': 'STDB CUT 2',
+                'name': 'STDB CUT 2',
                 'spare': None,
                 'talker': 'AI',
                 'to_bow': 0,
@@ -823,7 +823,7 @@ class TestAIS(unittest.TestCase):
                 'repeat': 0,
                 'second': 60,
                 'seq_id': None,
-                'shipname': 'STDB CUT 2',
+                'name': 'STDB CUT 2',
                 'spare': None,
                 'talker': 'AI',
                 'to_bow': 0,
diff --git a/tests/test_encode.py b/tests/test_encode.py
index 21e54b1..9a498dc 100644
--- a/tests/test_encode.py
+++ b/tests/test_encode.py
@@ -448,7 +448,8 @@ def test_encode_type_21():
     }
 
     encoded = encode_dict(data)
-    assert encoded[0] == "!AIVDO,1,1,,A,E4eHJhPP0000000000000000000KUOSc=rq4h00000a@2000000000000000,4*7E"
+    # Validated using: http://ais.tbsalling.dk/
+    assert encoded[0] == "!AIVDO,1,1,,A,E4eHJhPR37q0000000000000000KUOSc=rq4h00000a@2000000000000000,4*39"
 
 
 def test_encode_type_20():