Documentation
¶
Index ¶
- Constants
- Variables
- func GetRandBytes(size int) (b []byte, err error)
- type DV4Mini
- func (d *DV4Mini) Close()
- func (d *DV4Mini) FlushSerial() error
- func (d *DV4Mini) FlushTXBuffer()
- func (d *DV4Mini) GetRXBufferData() ([]byte, error)
- func (d *DV4Mini) GreenLedOff()
- func (d *DV4Mini) GreenLedOn()
- func (d *DV4Mini) RWRaw(data []byte)
- func (d *DV4Mini) ReadSerial(bufferSize int) ([]byte, error)
- func (d *DV4Mini) SetFrequency(txqrg, rxqrg []byte)
- func (d *DV4Mini) SetInitialSeed() error
- func (d *DV4Mini) SetOperatingMode(mode byte)
- func (d *DV4Mini) SetTXBuffer(size int) error
- func (d *DV4Mini) SetTXPower(pwr uint8)
- func (d *DV4Mini) Version() ([]byte, error)
- func (d *DV4Mini) WRaw(data []byte)
- func (d *DV4Mini) Watchdog() ([]byte, error)
- func (d *DV4Mini) WriteTXBufferData(data []byte)
Constants ¶
const ( SETADFQRG = 0x01 SETADFMODE = 0x02 FLUSHTXBUF = 0x03 ADFWRITE = 0x04 ADFWATCHDOG = 0x05 ADFGETDATA = 0x07 ADFGREENLED = 0x08 ADFSETPOWER = 0x09 ADFFLASHMODESET = 0x0b // captured from USB with dv4mini official software ADFFLASHMODE_0c = 0x0c // captured from USB with dv4mini official software ADFFLASHMODE_0d = 0x0d // captured from USB with dv4mini official software ADFFLASHMODE_0e = 0x0e // captured from USB with dv4mini official software ADFFLASHMODE_0f = 0x0f // captured from USB with dv4mini official software ADFDEBUG = 0x10 COMMAND_11 = 0x11 // captured from USB with dv4mini official software STRFWVERSION = 0x12 // captured from USB with dv4mini official software COMMAND_13 = 0x13 // captured from USB with dv4mini official software COMMAND_14 = 0x14 // captured from USB with dv4mini official software ADFSETSEED = 0x17 ADFVERSION = 0x18 ADFSETTXBUF = 0x19 )
Dongle commands
const ( MODE_DSTAR = 0x44 MODE_C4FM = 0x46 MODE_DMR = 0x4d MODE_DPRM = 0x4d MODE_P25 = 0x4d )
Dongle mode
const ( POWER_MIN POWER_1 POWER_2 POWER_3 POWER_4 POWER_5 POWER_6 POWER_7 POWER_8 POWER_MAX )
TX power constants
Variables ¶
var ( // Byte 1-4 Preamble; Byte 4 Command; Byte 5 Length of params; Byte 6-n Params CmdPreamble = []byte{0x71, 0xfe, 0x39, 0x1d} )
Functions ¶
func GetRandBytes ¶
Types ¶
type DV4Mini ¶
type DV4Mini struct {
Port *serial.Port
RSSIMSB uint8
RSSILSB uint8
RSSI int8
FWVersion string
DongleID string
}
func (*DV4Mini) FlushSerial ¶
Flush all the data available in the serial buffer
func (*DV4Mini) GetRXBufferData ¶
GetRXBufferData
func (*DV4Mini) RWRaw ¶
RWRaw sends a raw command to the dongle and reads out the response, useful for debugging purposes. The full packed must be crafted by hand with the format []byte{preamble, command, length, params}.
An example for getting dongle's version:
dv, err := dv4mini.Connect(DEVICE, true)
if err != nil {
log.Fatal(err)
}
// Make sure to close it later.
defer dv.Close()
c := []byte{
0x71, 0xfe, 0x39, 0x1d, // Preamble
0x18, // Command
0x00, // Length
}
buff, err dv.RWRaw(c)
[...]
func (*DV4Mini) ReadSerial ¶
ReadSerial
func (*DV4Mini) WRaw ¶
WRaw sends a raw command to the dongle, useful for debugging and testing purposes. The full packed must be crafted by hand with the format []byte{preamble, command, length, params}.
An example for setting the TX and RX frequency:
dv, err := dv4mini.Connect(DEVICE, true)
if err != nil {
log.Fatal(err)
}
// Make sure to close it later.
defer dv.Close()
c := []byte{
0x71, 0xfe, 0x39, 0x1d, // Preamble
0x01, // Command
0x08, // Length
0x19, 0xfc, 0xd3, 0x70, // TX freq.
0x19, 0xfc, 0xd3, 0x70, // RX freq.
}
dv.WRaw(c)
func (*DV4Mini) Watchdog ¶
Watchdog The DV4mini returns a ADFWATCHDOG message upon receiving this message.
func (*DV4Mini) WriteTXBufferData ¶
WriteTXBufferData writes to transmission buffer, the PTT (W/ red LED) is triggered automatically