Documentation
¶
Overview ¶
Example ¶
package main
import (
"fmt"
"github.com/tomoya0x00/go-im920"
"time"
)
func main() {
// This test will not be run, it has no "Output:" comment.
c := &im920.Config{Name: "COM4", ReadTimeout: 1 * time.Second}
im, err := im920.Open(c)
if err != nil {
fmt.Printf("Failed to open: %s\n", err)
return
}
defer im.Close()
id, err := im.GetId()
if err != nil {
fmt.Printf("Failed to GetId: %s\n", err)
return
}
fmt.Printf("ID: %v\n", id)
/*
err = im.AddRcvId(0x0001)
if err != nil {
fmt.Printf("Failed to AddRcvId: %s\n", err)
return
}
*/
version, err := im.IssueCommandRespStr("RDVR", "")
if err != nil {
fmt.Printf("Failed to RDVR: %s\n", err)
return
}
fmt.Printf("VERSION: %v\n", version)
/*
err = im.DeleteAllRcvId()
if err != nil {
fmt.Printf("Failed to DeleteAllRcvId: %s\n", err)
return
}
*/
rids, err := im.GetAllRcvId()
if err != nil {
fmt.Printf("Failed to GetAllRcvId: %s\n", err)
return
}
fmt.Printf("RIDS: %v\n", rids)
/*
err = im.SetCh(2, false)
if err != nil {
fmt.Printf("Failed to SetCh: %s\n", err)
return
}
*/
ch, err := im.GetCh()
if err != nil {
fmt.Printf("Failed to GetCh: %s\n", err)
return
}
fmt.Printf("CH: %v\n", ch)
rssi, err := im.GetRssi()
if err != nil {
fmt.Printf("Failed to GetRssi: %s\n", err)
return
}
fmt.Printf("RSSI: %v\n", rssi)
err = im.SetCommMode(im920.LONG_MODE, false)
if err != nil {
fmt.Printf("Failed to SetCommMode: %s\n", err)
return
}
mode, err := im.GetCommMode()
if err != nil {
fmt.Printf("Failed to GetCommMode: %s\n", err)
return
}
fmt.Printf("MODE: %v\n", mode)
data := []byte("0123456789")
_, err = im.Write(data)
if err != nil {
fmt.Printf("Failed to write: %s\n", err)
return
}
}
Output:
Index ¶
- type Ch
- type Config
- type IM920
- func (im *IM920) AddRcvId(id Id) (err error)
- func (im *IM920) Close() error
- func (im *IM920) DeleteAllRcvId() error
- func (im *IM920) GetAllRcvId() (ids []Id, err error)
- func (im *IM920) GetCh() (ch Ch, err error)
- func (im *IM920) GetCommMode() (mode Mode, err error)
- func (im *IM920) GetId() (id Id, err error)
- func (im *IM920) GetRssi() (rssi Rssi, err error)
- func (im *IM920) IsBusyFunc(f func() bool)
- func (im *IM920) IssueCommand(cmd, param string) (resp []byte, err error)
- func (im *IM920) IssueCommandNormal(cmd, param string) error
- func (im *IM920) IssueCommandRespNum(cmd, param string) (resp uint16, err error)
- func (im *IM920) IssueCommandRespNums(cmd, param string) (resp []uint16, err error)
- func (im *IM920) IssueCommandRespStr(cmd, param string) (resp string, err error)
- func (im *IM920) LastReadInfo() ReadInfo
- func (im *IM920) Read(p []byte) (n int, err error)
- func (im *IM920) SetCh(ch Ch, persist bool) (err error)
- func (im *IM920) SetCommMode(mode Mode, persist bool) (err error)
- func (im *IM920) Write(p []byte) (n int, err error)
- type Id
- type Mode
- type Node
- type ReadInfo
- type Rssi
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IM920 ¶
type IM920 struct {
// contains filtered or unexported fields
}
func (*IM920) DeleteAllRcvId ¶
func (*IM920) GetAllRcvId ¶
func (*IM920) GetCommMode ¶
func (*IM920) IsBusyFunc ¶
func (*IM920) IssueCommand ¶
func (*IM920) IssueCommandNormal ¶
func (*IM920) IssueCommandRespNum ¶
func (*IM920) IssueCommandRespNums ¶
func (*IM920) IssueCommandRespStr ¶
func (*IM920) LastReadInfo ¶
Click to show internal directories.
Click to hide internal directories.