canalyzecollect

package module
v0.0.0-...-e4a5bec Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 11, 2017 License: BSD-2-Clause Imports: 7 Imported by: 0

README

Canalyze Collect Go - Library in golang to capture CAN bus messages and save to a database for analysis

Install

  • Install libraries and utilities: > go get github.com/buffersandbeer/canalyzecollect/...
  • Install just the library: > go get github.com/buffersandbeer/canalyzecollect/

Docs

Documentation and usage explanations for the library can be found at https://godoc.org/github.com/buffersandbeer/canalyzecollect.

Tests

> go test is used for unit testing. No special dependencies are required for testing.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	DbURI    string
	Capturer string
}

Config contains the configuration to be used by canalyze

func (*Config) LoadConfig

func (c *Config) LoadConfig(path string) error

LoadConfig loads the configuration file based upon the file path provided

If the file does not exist or is not accessible, LoadConfig will return an error

type Database

type Database interface {
	Close() error                                                                               // Close the connection to the database
	Ping() (bool, error)                                                                        // Check that the database is still there
	AddContext(capturer string, captureName string, details string, target string) (int, error) // Create context entry
	AddCandumpFrame(packet string, context int) error                                           // Add unparsed data from SocketCan/Candump to the database
	AddRawFrame(frame canlib.RawCanFrame, context int) error                                    // Add raw frames to the database that have not been processed
	AddProcessedFrame(frame canlib.ProcessedCanFrame, context int) error                        // Add processed frames to the database
}

Database is an interface that defines a type that can interact with the various databases this framework supports

type PostgresDB

type PostgresDB struct {
	Con       *sql.DB
	Connected bool
	// contains filtered or unexported fields
}

PostgresDB will manage transactions with a PostgreSQL database

func CreatePostgres

func CreatePostgres(conf Config) (*PostgresDB, error)

CreatePostgres will connect to the Postgres DB and update the pdb struct to contain that connection

func (PostgresDB) AddCandumpFrame

func (pdb PostgresDB) AddCandumpFrame(packet string, context int) error

AddCandumpFrame will add a can frame captured by Socketcan/candump to the database

func (PostgresDB) AddContext

func (pdb PostgresDB) AddContext(capturer string, captureName string, details string, target string) (int, error)

AddContext will add a context row to the database and return the ID of that context

func (PostgresDB) AddProcessedFrame

func (pdb PostgresDB) AddProcessedFrame(frame canlib.ProcessedCanFrame, context int) error

AddProcessedFrame will add a processed can frame into the database

func (PostgresDB) AddRawFrame

func (pdb PostgresDB) AddRawFrame(frame canlib.RawCanFrame, context int) error

AddRawFrame will add a raw frame to the database

func (*PostgresDB) Close

func (pdb *PostgresDB) Close() error

Close will close the database connection

func (PostgresDB) Ping

func (pdb PostgresDB) Ping() (bool, error)

Ping will try to ping the database

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL