-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #64 from M0r13n/63-fix-inconsistencies
Fix inconsistencies and add a 'rate_of_turn' property to typ 1,2,3 me…
- Loading branch information
Showing
12 changed files
with
733 additions
and
323 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import bitarray | ||
|
||
from pyais import decode | ||
from pyais.util import bits2bytes, bytes2bits | ||
|
||
# This is a message of type 6 which contains binary payload | ||
msg = decode(b"!AIVDM,1,1,,B,6B?n;be:cbapalgc;i6?Ow4,2*4A") | ||
|
||
assert msg.msg_type == 6 | ||
|
||
# The payload is bytes by default | ||
assert msg.data == b'\xeb/\x11\x8f\x7f\xf1' | ||
|
||
|
||
# But using `bytes2bits` you can convert the bytes into a bitarray | ||
assert bytes2bits(msg.data) == bitarray.bitarray('111010110010111100010001100011110111111111110001') | ||
|
||
# Or to a bitstring using the bitarray to01() method | ||
assert bytes2bits(msg.data).to01() == '111010110010111100010001100011110111111111110001' | ||
|
||
# It is also possible to transform a set of bits back to bytes | ||
assert bits2bytes('111010110010111100010001100011110111111111110001') == b'\xeb/\x11\x8f\x7f\xf1' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.