bla
This commit is contained in:
parent
b40ce2d243
commit
b8fcce1996
3 changed files with 5 additions and 4 deletions
|
@ -66,7 +66,7 @@ func SetSpeedConfig(speed int, minDistance, maxDistance, minSpeed, maxSpeed, tri
|
||||||
}
|
}
|
||||||
|
|
||||||
func SetCommunicationConfig() {
|
func SetCommunicationConfig() {
|
||||||
err := r.SetCommunicationConfig(radar_lib.PortRS485, radar_lib.Baud115200, radar_lib.OutputTypeNoOutput, radar_lib.OutputTypeNoOutput, radar_lib.OutputTypeNoOutput, 50)
|
err := r.SetCommunicationConfig(radar_lib.PortRS485, radar_lib.Baud115200, radar_lib.OutputTypeValidOutput, radar_lib.OutputTypeNoOutput, radar_lib.OutputTypeNoOutput, 50)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("%v", err)
|
log.Printf("%v", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,6 +104,7 @@ type Radar struct {
|
||||||
func (r *Radar) write(data []byte) error {
|
func (r *Radar) write(data []byte) error {
|
||||||
r.lock.Lock()
|
r.lock.Lock()
|
||||||
defer r.lock.Unlock()
|
defer r.lock.Unlock()
|
||||||
|
log.Printf("%v", data)
|
||||||
n, err := r.port.Write(data)
|
n, err := r.port.Write(data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -124,9 +125,8 @@ func (r *Radar) SetPinTrigger(controlPin int, distance int, outputLevel int, dir
|
||||||
// SetBaseConfig configures the base configuration. height defines the mounted height in 1cm steps, angle defines the vertical angle in degrees, waveformConfig is used to differentiate 2 different radars
|
// SetBaseConfig configures the base configuration. height defines the mounted height in 1cm steps, angle defines the vertical angle in degrees, waveformConfig is used to differentiate 2 different radars
|
||||||
func (r *Radar) SetBaseConfig(height int, angle int, waveformConfig int) error {
|
func (r *Radar) SetBaseConfig(height int, angle int, waveformConfig int) error {
|
||||||
data := startSequence
|
data := startSequence
|
||||||
data = append(data, 0x01, byte(height), byte(angle), byte(waveformConfig), 0x00, 0x00)
|
data = append(data, 0x01, byte(height), byte(angle), byte(waveformConfig), 0x00)
|
||||||
data = append(data, endSequence...)
|
data = append(data, endSequence...)
|
||||||
log.Printf("%v", data)
|
|
||||||
return r.write(data)
|
return r.write(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,9 +18,10 @@ func (r *Radar) listenSerial() {
|
||||||
log.Println("\nEOF")
|
log.Println("\nEOF")
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
for i := 0; i < n; i++ {
|
for i := range n {
|
||||||
rcvBuf[lastIndex] = buf[i]
|
rcvBuf[lastIndex] = buf[i]
|
||||||
if i > 1 && buf[i-1] == 0x0D && buf[i] == 0x0A {
|
if i > 1 && buf[i-1] == 0x0D && buf[i] == 0x0A {
|
||||||
|
log.Printf("%v", buf)
|
||||||
r.decodeInput(rcvBuf[0 : lastIndex+1])
|
r.decodeInput(rcvBuf[0 : lastIndex+1])
|
||||||
lastIndex = 0
|
lastIndex = 0
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Reference in a new issue