Skip to content

SigTuple/lis1a2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LIS1A2 - A Go library

Standard implementation for the lis1a2 protocol. This library is extensible, so instead of using a TCP connection, the user can use any other standard for communication like RS232 provided it adheres to the Connection interface provided in the library.

Features

  • Adheres to LIS1A2 Standard
  • Implementation for TCP Connection adhering to Connection interface is provided.

Installation

go get github.com/SigTuple/lis1a2

Usage

The user needs to initialize the Connection object. We'll use the TCP implementation bundled with the library. The user needs to use the connection object to create a ASTM Connection.

package main

import (
	"log"

	"github.com/SigTuple/lis1a2"
	"github.com/SigTuple/lis1a2/connection"
)

func main() {
	var tcpConn = connection.NewTCPConnection("localhost", "4000")

	var astmConn = lis1a2.NewASTMConnection(&tcpConn, false)
	err := astmConn.Connect()
	if err != nil {
		log.Fatalf("Failed to connect to the ASTM Service")
	}
	defer func(astmConn *lis1a2.ASTMConnection) {
		err := astmConn.Disconnect()
		if err != nil {

		}
	}(astmConn)
}

To send a new message to the astm connection the user needs to establish send mode

package main

import (
	"log"
	
	"github.com/SigTuple/lis1a2"
)

func SendMessageToConnection(astmConn lis1a2.ASTMConnection, data []byte) {
	establishedSendMode := astmConn.EstablishSendMode()
	if !establishedSendMode {
		log.Fatal("Could not establish send mode.")
	}
	astmConn.SendMessage(data)
	astmConn.StopSendMode()
}

About

An open source LIS1A2 library written in Go.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages