Skip to main content

AIS140 Protocol Parser

Project description

AIS-140 Protocol Parser

This is a Python library that parses AIS-140 protocol messages used for tracking public and commercial vehicles. The parser extracts latitude, longitude, speed, and GPS status from raw messages, and validates checksums if present.

Installation

Alternatively, you can install with pip: pip install ais140-parser

Basic Usage

To install the library, clone the repository and install the dependencies:

git clone https://github.com/your-username/ais140-parser.git
cd ais140-parser
pip install .


Alternatively, you can install with pip:
    pip install ais140-parser

Basic Usage
The simplest way to use  ais140-parser library for parsing your data and analyze it.
    from ais140.parser import AIS140Parser
    from ais140.kpi import AIS140KPI

    def main():
        # Create an instance of the parser
        parser = AIS140Parser()

        # Define a list of AIS-140 packets (could also be read from a file), below are sample data. 
        packets = [
            "$PKT,VID1234,FW1.2.3,NR,1,N,123456789012345,KA01AB1234,100,22,0,130425,143015,12.971598,N,77.594566,E,48.5,270.0,10,920.0,1.8,0.9,Airtel,1,1,12.6,0,0,000123,404,45,5678,123456,25",
            "$LGN,istartracker,andy123456,867458047932167,V100,AIS140,22.678880,N,114.047001,E", 
            "$HBT,istartracker,V100,HP,867458047932167,94%,20%,0.00%,20,30,0000,00,0.0,0.0*",
            "$EPB,istartracker,EMR,867458047932167,NM,02012020062650,A,22.678373,N,114.046198,E,80,1,1863,G,car123456,,473A0F35 "
        ]

        # Parse the packets into tracking, health, logging, and unknown dataframes
        tracking_df, health_df, logging_df, unknown_df = parser.parse_packets(packets)

        # Output the valid tracking packets
        print("Tracking Packets:")
        print(tracking_df)

        # Output the health packets
        print("\nHealth Packets:")
        print(health_df)

        # Output the logging packets
        print("\nLogging Packets:")
        print(logging_df)

        # Output the unknown packets
        print("\nUnknown Packets:")
        print(unknown_df)

        #KPI Analysis
        tracking_df, *_ = parser.parse_packets(packets)
        
        kpi = AIS140KPI(tracking_df)

        print("Total Devices:", kpi.total_devices())
        print("Online Devices:", kpi.online_devices())
        print("Offline Devices:", kpi.offline_devices())
        print("Average Speed:", kpi.average_speed())
        print("Over-speeding Devices:", kpi.overspeeding_devices())
        print("Current Locations:\n", kpi.current_locations())


    if __name__ == "__main__":
        main()

#Output should be like below Total Devices: 1
    '''Online Devices: 0
    Offline Devices: 1
    Average Speed: 48.5
    Over-speeding Devices: 0
    Current Locations:
                imei   latitude  longitude
    0  123456789012345  12.971598  77.594566'''

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ais140_parser-1.0.0.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ais140_parser-1.0.0-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file ais140_parser-1.0.0.tar.gz.

File metadata

  • Download URL: ais140_parser-1.0.0.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.7

File hashes

Hashes for ais140_parser-1.0.0.tar.gz
Algorithm Hash digest
SHA256 c9111910ffd42e1e63d6513a7b421d4f83263c42351d2d80ddf8fea15e291943
MD5 adc1245540fa6c5cf71fa31091dea5d9
BLAKE2b-256 67b6970b68eee4db65ef9f71e32caa21a806e7c9f3a522e36b376facf9fb09ae

See more details on using hashes here.

File details

Details for the file ais140_parser-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: ais140_parser-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.7

File hashes

Hashes for ais140_parser-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 937515c8539e14f662421a4b6c16e598355ffa70e3794b373352ffade4eee506
MD5 a7b712ae7ca3d8ad31bf4c79064b9ca3
BLAKE2b-256 603ee8dbf17a51a49218a8d50a56d9071ff7ca7c6230cb182938aa043dd6b24a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page