dv4mini

package module
v0.0.0-...-6e64d49 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2016 License: Apache-2.0 Imports: 7 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

dv4mini

dv4mini is a interfacing library for the dv4mini dongle written in go.

Serial configuration

BaudRate:        115200,
DataBits:        8,
StopBits:        1,
ParityMode:      0,

Example

USB commands

  • SETADFQRG (0x01)
  • SETADFMODE (0x02)
  • FLUSHTXBUF (0x03)
  • ADFWRITE (0x04)
  • ADFWATCHDOG (0x05)
  • ADFGETDATA (0x07)
  • ADFGREENLED (0x08)
  • ADFSETPOWER (0x09)
  • ADFDEBUG (0x10)
  • ???????? (0x11)
  • STRFWVERSION (0x12)
  • ???????? (0x13)
  • ???????? (0x14)
  • ADFSETSEED (0x17)
  • ADFVERSION (0x18)
  • ADFSETTXBUF (0x19)
  • ADFFLASHSET (0x0b)
  • ADFFLASH0c (0x0c)
  • ADFFLASH0d (0x0d)
  • ADFFLASH0e (0x0e)
  • ADFFLASH0f (0x0f)
SETADFQRG = 1
Set the QRG of Receiver and Transmitter. The RX qrg is set immediately. The TX qrg is set with the next transmission.
Length: 8
Parameters:
    Byte 0 RX-qrg LSB
    Byte 1 RX-qrg
    Byte 2 RX-qrg
    Byte 3 RX-qrg MSB
    Byte 4 TX-qrg LSB
    Byte 5 TX-qrg
    Byte 6 TX-qrg
    Byte 7 TX-qrg MSB
In DMR mode only simplex (RX=TX qrg) is allowed.

 |_________________|435.999.600|435.999.600| < hz
 |_preamble__|C_|S_|0_|1_|2_|3_|4_|5_|6_|7_|8_|9_|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|
< 71 fe 39 1d 01 08 19 fc d3 70 19 fc d3 70

19 fc d5 70 > 436.000.000
SETADFMODE = 2
Set the operating mode
Length: 1
Parameters:
Byte 0 ... mode
mode:
    'D' = Dstar
    'M' = DMR
    'F' = Fusion C4FM
    ''  = P25
    ''  = dPRM
    'T' = TX
    'R' = RX

 |_preamble__|C_|S_|0_|1_|2_|3_|4_|5_|6_|7_|8_|9_|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|
< 71 fe 39 1d 02 01 44 (D-Star)
< 71 fe 39 1d 02 01 4d (DMR)
< 71 fe 39 1d 02 01 46 (C4FM)
< 71 fe 39 1d 02 01 4d (P25)
< 71 fe 39 1d 02 01 4d (dPRM)

### FLUSHTXBUF = 3

Sends all data from the TX buffer
length: 0
no parameters

### ADFWRITE = 4

Write binary data to the transmit buffer. The data are then transmitted as
soon as the TX buffer is filled (see also ADFSETTXBUF).
The PTT is keyed automatically, a preamble is sent automatically.
Length: 1 to 245
Parameters: binary data stream to be sent. MSB is sent first.

 |_preamble__|C_|S_|0_|1_|2_|3_|4_|5_|6_|7_|8_|9_|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|
< 71 fe 39 1d 04 24 23 7f f5 9c 4e c8 d2 fc 28 eb bf f5 9c 4e c8 2e 0c 0a 22 0a e8 d0 f8 0e
< 71 fe 39 1d 04 24 23 7d e4 64 93 86 79 79 76 22 d7 e7 41 30 84 2e 0c 0a 22 0a e8 9c f3 73

### ADFWATCHDOG = 5

The DV4mini returns a ADFWATCHDOG message upon receiving this message:
length: 0
no parameter
The DV4mini returns the following data:
Command: ADFWATCHDOG
length: 8
    Byte 0 ... RSSI MSB
    Byte 1 ... RSSI LSB
    Byte 2,3,4 ADF Version
    Byte 5,6,7 Dongle serial number

Used to read the RSSI and also to check if the DV4mini is alive and connected.

 |_preamble__|C_|S_|0_|1_|2_|3_|4_|5_|6_|7_|8_|9_|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|
< 71 FE 39 1D 05 00
                   |                       8
 |______________|__|__|__|________|________|????
 |_preamble__|C_|S_|0_|1_|2_|3_|4_|5_|6_|7_|8_|9_|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|
> 71 fe 39 1d 05 28 ff d1 00 01 64 32 54 ff e8 e6 79 34 55 b5 8d 00 a3 f8 fe bc 41 60 e5 d8 07
  b6 b0 da
> 71 fe 39 1d 05 28 ff 9a 00 01 64 32 54 ff 24 14 3a 4c 8b 59 0e 21 ee db 27 0c 8c 4d bc da 4b
  a8 53 cb

### ADFGETDATA = 7

Request the contents of the receive buffer.
Length: 0
no parameters
the DV4mini returns an ADFGETDATA message with variable length. The parameter field contains the contents of the RX buffer.

 |_preamble__|C_|S_|0_|1_|2_|3_|4_|5_|6_|7_|8_|9_|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|
< 71 fe 39 1d 07 00
 |_preamble__|C_|S_|0_|1_|2_|3_|4_|5_|6_|7_|8_|9_|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|
> 71 fe 39 1d 07 14 c2 04 e8 9a ad 0e aa 6f 91 9f 82 ae ad 7a
> 71 fe 39 1d 07 13 67 29 d5 51 53 54 ef 57 de d9 46 bc b5
> 71 fe 39 1d 07 13 66 3e f1 d4 44 d5 29 55 47 df 75 41 f1

### ADFGREENLED = 8

Swicth on/of the green LED to show an RX sync
Length: 1
Parameters:
    Byte 0 ... 0=off, 1=on
As soon as the host software recognizes a SYNC it can switch on the green LED.

 |_preamble__|C_|S_|0_|1_|2_|3_|4_|5_|6_|7_|8_|9_|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|
< 71 fe 39 1d 08 01 01 (On)
 |_preamble__|C_|S_|0_|1_|2_|3_|4_|5_|6_|7_|8_|9_|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|
< 71 fe 39 1d 08 01 00 (off)

### ADFSETPOWER = 9

Set the output power of the DV4mini 70cm transmitter.
Length: 1
Parameters:
    Byte 0 ... value from 0(min) to 9(max)

 |_preamble__|C_|S_|0_|1_|2_|3_|4_|5_|6_|7_|8_|9_|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|
< 71 fe 39 1d 09 01 09

### ADFDEBUG = 10

This is only sent from DV4mini to the host.
It contains a variable length string with debug messages which can be printed out.

### ??? 11

NFI

 |_preamble__|C_|S_|0_|1_|2_|3_|4_|5_|6_|7_|8_|9_|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|
? 71 fe 39 1d 11 04 03 d6 46 ec

### GETSTRADFVERSION = 12

Returns string ADF version.

 |_preamble__|C_|S_|0_|1_|2_|3_|4_|5_|6_|7_|8_|9_|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|
< 71 fe 39 1d 12 00
> 71 fe 39 1d 12 07 56 30 31 2e 36 34 00
??? 13
NFI

Is 0f the only value?

 |_preamble__|C_|S_|0_|1_|2_|3_|4_|5_|6_|7_|8_|9_|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|
? 71 fe 39 1d 13 01 0f
??? 14
NFI

 |_preamble__|C_|S_|0_|1_|2_|3_|4_|5_|6_|7_|8_|9_|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|
? 71 fe 39 1d 14 02 00 00

 |_preamble__|C_|S_|0_|1_|2_|3_|4_|5_|6_|7_|8_|9_|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|
? 71 fe 39 1d 14 02 01 00

### ADFSETSEED = 17

Write a random number to the DV4mini stick which is then used as seed for
random functions. Length: 4
Parameters:
    Byte 0 value LSB Byte 1 value
    Byte 2 value
    Byte 3 value MSB
"value" is a random numer. The host PC usually takes this from the internal clock.

 |_preamble__|C_|S_|0_|1_|2_|3_|4_|5_|6_|7_|8_|9_|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|

### ADFVERSION = 18

Length: 0
no parameters
The DV4mini returns an ADFVERSION message including a variable length string with the version number of the firmware.

 |_preamble__|C_|S_|0_|1_|2_|3_|4_|5_|6_|7_|8_|9_|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|

### ADFSETTXBUF = 19

Sets the size of the transmit buffer. This buffer is used to handle gaps in the received data stream. Length: 1
Parameters:
    Byte 0 ... buffer size in 100ms steps (min:100ms max:1500ms which is min:1 and max:15)

 |_preamble__|C_|S_|0_|1_|2_|3_|4_|5_|6_|7_|8_|9_|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|

ADFFLASHSET = 0b
Enter into firmware flash mode

Length: 1
params:
    Byte 0 0x01

 |_preamble__|C_|S_|0_|1_|2_|3_|4_|5_|6_|7_|8_|9_|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|
< 71 fe 39 1d 0b 01 01
ADFFLASH0c = 0c
ADFFLASH0d = 0d
ADFFLASH0e = 0e
ADFFLASH0f = 0f

Documentation

Index

Constants

View Source
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

View Source
const (
	MODE_DSTAR = 0x44
	MODE_C4FM  = 0x46
	MODE_DMR   = 0x4d
	MODE_DPRM  = 0x4d
	MODE_P25   = 0x4d
)

Dongle mode

View Source
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

View Source
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

func GetRandBytes(size int) (b []byte, err error)

Types

type DV4Mini

type DV4Mini struct {
	Port      *serial.Port
	RSSIMSB   uint8
	RSSILSB   uint8
	RSSI      int8
	FWVersion string
	DongleID  string
}

func Connect

func Connect(device string, dbg bool) (*DV4Mini, error)

Connect opens the DV4mini serial device

func (*DV4Mini) Close

func (d *DV4Mini) Close()

Close closes serial connection

func (*DV4Mini) FlushSerial

func (d *DV4Mini) FlushSerial() error

Flush all the data available in the serial buffer

func (*DV4Mini) FlushTXBuffer

func (d *DV4Mini) FlushTXBuffer()

FlushTXBuffer

func (*DV4Mini) GetRXBufferData

func (d *DV4Mini) GetRXBufferData() ([]byte, error)

GetRXBufferData

func (*DV4Mini) GreenLedOff

func (d *DV4Mini) GreenLedOff()

GreenLedOff sets the green LED off

func (*DV4Mini) GreenLedOn

func (d *DV4Mini) GreenLedOn()

GreenLedOn sets the green LED on

func (*DV4Mini) RWRaw

func (d *DV4Mini) RWRaw(data []byte)

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

func (d *DV4Mini) ReadSerial(bufferSize int) ([]byte, error)

ReadSerial

func (*DV4Mini) SetFrequency

func (d *DV4Mini) SetFrequency(txqrg, rxqrg []byte)

SetFrequency

func (*DV4Mini) SetInitialSeed

func (d *DV4Mini) SetInitialSeed() error

SetInitialSeed

func (*DV4Mini) SetOperatingMode

func (d *DV4Mini) SetOperatingMode(mode byte)

SetOperatingMode

func (*DV4Mini) SetTXBuffer

func (d *DV4Mini) SetTXBuffer(size int) error

SetTXBuffer

func (*DV4Mini) SetTXPower

func (d *DV4Mini) SetTXPower(pwr uint8)

SetTXPower

func (*DV4Mini) Version

func (d *DV4Mini) Version() ([]byte, error)

Version returns the firmware version and dongle ID byte array.

func (*DV4Mini) WRaw

func (d *DV4Mini) WRaw(data []byte)

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

func (d *DV4Mini) Watchdog() ([]byte, error)

Watchdog The DV4mini returns a ADFWATCHDOG message upon receiving this message.

func (*DV4Mini) WriteTXBufferData

func (d *DV4Mini) WriteTXBufferData(data []byte)

WriteTXBufferData writes to transmission buffer, the PTT (W/ red LED) is triggered automatically

Jump to

Keyboard shortcuts

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