dms3libs

package
v0.0.0-...-f5cca22 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package dms3libs audio provides audio services for dms3 device components

Package dms3libs configuration structures and variables

Package dms3libs detector provides motion detector application services for dms3 device components

Package dms3libs file provides file services for dms3 device components

Package dms3libs log provides logging services for dms3 device components

Package dms3libs network provides networking services for dms3 device components

Package dms3libs OS provides operating system information services for dms3 device components

Package dms3libs util provides utility services for dms3 device components

Index

Constants

This section is empty.

Variables

View Source
var (
	Fatal *log.Logger
	Info  *log.Logger
	Debug *log.Logger
)

global logging objects

View Source
var LibConfig *structConfig

LibConfig contains dms3Libs configuration settings read from TOML file

View Source
var MotionDetector = structMotionDetector{
	// contains filtered or unexported fields
}

MotionDetector is the motion detector application running on the clients (e.g., motion)

Functions

func CheckErr

func CheckErr(err error)

CheckErr does simple error management (no logging dependencies)

func CheckFileLocation

func CheckFileLocation(configPath string, fileDir string, fileLocation *string, filename string)

CheckFileLocation checks/sets the location of file and pathname passed in as defined in various TOML config files, returning a fully qualified path

func CopyDir

func CopyDir(srcDir string, destDir string)

CopyDir copies a directory from srcDir to destDir

func CopyFile

func CopyFile(src string, dest string)

CopyFile copies a file from src to dest

func CountFilesInDir

func CountFilesInDir(srcDir string) int

CountFilesInDir recursively counts the files in the dir passed in

func CreateLogger

func CreateLogger(logger *StructLogging)

CreateLogger creates an application log file (1) or redirects to STDOUT (2) based on logDevice

func FindMacs

func FindMacs(macsToFind []string) bool

FindMacs uses 'ip neigh' to find mac address(es) passed in, returning true if any mac passed in is found (e.g., mac1|mac2|mac3)

func Format24H

func Format24H(time string) string

Format24H formats 24-hour time to six places (HHMMSS)

func FormatDateTime

func FormatDateTime(value time.Time) string

FormatDateTime formats time to "date at time"

func GetDeviceDetails

func GetDeviceDetails(element DeviceDetails) string

GetDeviceDetails returns device details of the local machine

func GetDeviceHostname

func GetDeviceHostname() string

GetDeviceHostname returns the name of the local machine

func GetDeviceOSName

func GetDeviceOSName() string

GetDeviceOSName returns the OS release name (NAME) and version ID (VERSION_ID) from a parse of the /etc/os-release file found in most Linux-based distributions

func GetFunctionName

func GetFunctionName() string

GetFunctionName uses reflection (runtime) to return current function name

func GetGitVersion

func GetGitVersion() string

FUTURE USE: GetGitVersion queries the external git runtime for the most recent version tag, returning a string to the caller

func GetImageDimensions

func GetImageDimensions(imagePath string) (int, int)

GetImageDimensions returns the (width, height) of an image passed in

func GetPackageDir

func GetPackageDir() string

GetPackageDir returns the absolute path of the calling package

func IsFile

func IsFile(filename string) bool

IsFile returns true/false on existence of file/folder passed in

func IsRunning

func IsRunning(application string) bool

IsRunning checks if application is currently running (has PID > 0)

func LoadComponentConfig

func LoadComponentConfig(structConfig interface{}, configFile string)

LoadComponentConfig loads a TOML configuration file of client/server configs into parameter values

func LoadLibConfig

func LoadLibConfig(configFile string)

LoadLibConfig loads a TOML configuration file of system commands into parameter values

func LogDebug

func LogDebug(msg string)

LogDebug generates a debug log message based on loggingLevel

func LogFatal

func LogFatal(msg string)

LogFatal generates a fatal log message based on loggingLevel

func LogInfo

func LogInfo(msg string)

LogInfo generates an informational log message based on loggingLevel

func MkDir

func MkDir(newPath string)

MkDir creates a new folder with permissions passed in

func ModVal

func ModVal(number int, val int) int

ModVal returns the remainder of number/val passed in

func PingHosts

func PingHosts(ipBase string, ipRange []int)

PingHosts uses native ping command to ping the address range passed in to freshen the local arp cache

func PlayAudio

func PlayAudio(audioFile string)

PlayAudio uses the shell aplay command (system default) to play audioFile

func RmDir

func RmDir(dir string)

RmDir removes the folder passed in

func RunCommand

func RunCommand(cmd string) (res []byte, err error)

RunCommand is a simple wrapper for the exec.Command() call

NOTE: this call is blocking (non-threaded), and will return only after the command completes

func SecondsSince

func SecondsSince(value time.Time) uint32

SecondsSince returns seconds passed since value passed

func SetLogFileLocation

func SetLogFileLocation(config *StructLogging)

SetLogFileLocation sets the location of the log file based on TOML configuration

func StartStopApplication

func StartStopApplication(state MotionDetectorState, application string) bool

StartStopApplication enable/disables the application passed in

func StripRet

func StripRet(value []byte) []byte

StripRet strips the rightmost byte from the byte array

func To24H

func To24H(value time.Time) string

To24H converts 12-hour time to 24-hour time, returning a string (e.g., "231305")

func Uptime

func Uptime(startTime time.Time) string

Uptime returns uptime for the application process

func WalkDir

func WalkDir(dirname string) map[string]int

WalkDir generates a map of directories (0) and files (1)

Types

type DeviceDetails

type DeviceDetails int

DeviceDetails defines the set of available device details available in GetDeviceDetails

const (
	Sysname DeviceDetails = iota
	Machine
	Release
)

types of DMS3 devices

type MotionDetectorState

type MotionDetectorState int

MotionDetectorState defines the motion detector application state type

const (
	Stop MotionDetectorState = iota
	Start
)

states of the motion detector application

type StructLogging

type StructLogging struct {
	LogLevel    int
	LogDevice   int
	LogFilename string
	LogLocation string
}

StructLogging is used for dms3 logging

Jump to

Keyboard shortcuts

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