ld2451

package module
v0.0.0-...-0aa71f5 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2025 License: MIT Imports: 6 Imported by: 0

README

ld2451

golang library for HiLink HLK LD2451 board

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	SerialPort       string
	BaudRate         int
	TargetBufferSize int //Size of the channel buffer to store targets in
}

type Direction

type Direction uint8
const (
	DirectionAway   Direction = 0
	DirectionToward Direction = 1
	DirectionAll    Direction = 2
)

func (Direction) String

func (d Direction) String() string

type LD2451

type LD2451 struct {
	// contains filtered or unexported fields
}

func OpenLD2451

func OpenLD2451(config Config) (*LD2451, error)

func (*LD2451) Close

func (ld2451 *LD2451) Close()

func (*LD2451) EnableConfigCmd

func (ld2451 *LD2451) EnableConfigCmd() error

Enabling Configuration Commands Any other command issued to the radar must be executed after this command is issued, otherwise it will be invalid.

func (*LD2451) EndConfigCmd

func (ld2451 *LD2451) EndConfigCmd() error

End configuration command End the configuration command, and the radar will resume working mode after execution. If you need to send other commands again, you need to send the enable configuration command first.

func (*LD2451) GetFirmwareVersion

func (ld2451 *LD2451) GetFirmwareVersion() (string, error)

func (*LD2451) GetRadarSensitivity

func (ld2451 *LD2451) GetRadarSensitivity() (trigger_times bool, snr uint8, err error)

This command queries the motion sensitivity of each range gate.

func (*LD2451) GetTargetDetectionCfg

func (ld2451 *LD2451) GetTargetDetectionCfg() (max_distance uint8, direction Direction, min_speed uint8, target_delay uint8, err error)

Read target detection parameter command This command can read the radar's current target detection parameters.

func (*LD2451) ReadTarget

func (ld2451 *LD2451) ReadTarget() (Target, error)

func (*LD2451) ReadTargetNoBlock

func (ld2451 *LD2451) ReadTargetNoBlock() (*Target, error)

func (*LD2451) RestartModule

func (ld2451 *LD2451) RestartModule() error

When the module receives this command, it will automatically restart after the response is sent.

func (*LD2451) RestoreFactorySettings

func (ld2451 *LD2451) RestoreFactorySettings() error

This command is used to restore all configuration values to factory settings. The configuration values take effect after the module is restarted.

func (*LD2451) SetRadarSensitivity

func (ld2451 *LD2451) SetRadarSensitivity(trigger_times bool, snr uint8) error

Radar sensitivity parameter configuration command

func (*LD2451) SetSerialPortBaudRate

func (ld2451 *LD2451) SetSerialPortBaudRate(serial_rate SerialPortBaudRate) error

Setting the serial port baud rate This command is used to set the baud rate of the module serial port. The configuration value will not be lost when the power is off. The configuration value will take effect after the module is restarted.

func (*LD2451) SetTargetDetectionCfg

func (ld2451 *LD2451) SetTargetDetectionCfg(max_distance uint8, direction Direction, min_speed uint8, target_delay uint8) error

Target detection parameter configuration commands Any other command issued to the radar must be executed after this command is issued, otherwise it will be invalid.

func (*LD2451) StartReadThread

func (ld2451 *LD2451) StartReadThread()

func (*LD2451) StartSyncReadThread

func (ld2451 *LD2451) StartSyncReadThread()

func (*LD2451) StopReadThread

func (ld2451 *LD2451) StopReadThread()

type SerialPortBaudRate

type SerialPortBaudRate uint8
const (
	SerialPortBaudRate9600   SerialPortBaudRate = 0x0001
	SerialPortBaudRate19200  SerialPortBaudRate = 0x0002
	SerialPortBaudRate38400  SerialPortBaudRate = 0x0003
	SerialPortBaudRate57600  SerialPortBaudRate = 0x0004
	SerialPortBaudRate115200 SerialPortBaudRate = 0x0005 // default
	SerialPortBaudRate230400 SerialPortBaudRate = 0x0006
	SerialPortBaudRate256000 SerialPortBaudRate = 0x0007
	SerialPortBaudRate460800 SerialPortBaudRate = 0x0008
)

type Target

type Target struct {
	Angle     int       // Angle of the target relative to the perpendicular direction of the antenna
	Distance  int       // Distance in meters to the target
	Direction Direction // Direction of movement relative to the antenna
	Speed     int       // Speed in KM/H
	SNR       int       // Signal to Noise Ratio
}

Jump to

Keyboard shortcuts

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