Documentation
¶
Index ¶
- Constants
- Variables
- func GetAdapterMap() map[string]*AdapterInfo
- func IsRecoverable(err error) bool
- func List() []string
- func RegisterAdapter(adapter *AdapterInfo) error
- func Unrecoverable(err error) error
- type Adapter
- type AdapterCapabilities
- type AdapterConfig
- type AdapterInfo
- type CANFrame
- type CANFrameType
- type Client
- func (c *Client) Adapter() Adapter
- func (c *Client) Close() (err error)
- func (c *Client) Err() <-chan error
- func (c *Client) Send(identifier uint32, data []byte, f CANFrameType) error
- func (c *Client) SendAndWait(ctx context.Context, frame *CANFrame, timeout time.Duration, ...) (*CANFrame, error)
- func (c *Client) SendExtended(identifier uint32, data []byte, f CANFrameType) error
- func (c *Client) SendFrame(msg *CANFrame) error
- func (c *Client) Subscribe(ctx context.Context, identifiers ...uint32) *Sub
- func (c *Client) SubscribeChan(ctx context.Context, channel chan *CANFrame, identifiers ...uint32) *Sub
- func (c *Client) SubscribeFunc(ctx context.Context, f func(*CANFrame), identifiers ...uint32) *Sub
- func (c *Client) Wait(ctx context.Context, timeout time.Duration, identifiers ...uint32) (*CANFrame, error)
- type Handler
- type Opts
- type Sub
Constants ¶
const ( SystemMsg uint32 = 0x80000000 + iota SystemMsgError SystemMsgUnrecoverableError SystemMsgWBLReading SystemMsgDataResponse SystemMsgDataRequest SystemMsgWriteResponse SystemMsgUnknown )
We have 3 bits allowing 8 different system messages hidden in a 29bit can id stored in a uint32
Variables ¶
var ( ErrDroppedFrame = errors.New("adapter incoming channel full") ErrFramhandlerRegisterSub = errors.New("failed to register subscription, framehandler is full") )
var ( Incoming = CANFrameType{Type: 0, Responses: 0} Outgoing = CANFrameType{Type: 1, Responses: 0} // Used for ELM and STN adapters to signal we want the adapter to wait for a response ResponseRequired = CANFrameType{Type: 2, Responses: 1} )
Functions ¶
func GetAdapterMap ¶ added in v1.0.8
func GetAdapterMap() map[string]*AdapterInfo
func IsRecoverable ¶ added in v1.0.1
IsRecoverable checks if error is an instance of `unrecoverableError`
func RegisterAdapter ¶ added in v1.0.7
func RegisterAdapter(adapter *AdapterInfo) error
func Unrecoverable ¶ added in v1.0.1
Unrecoverable wraps an error in `unrecoverableError` struct
Types ¶
type Adapter ¶
type Adapter interface {
Name() string
Open(context.Context) error
Close() error
Send() chan<- *CANFrame
Recv() <-chan *CANFrame
Err() <-chan error
}
func NewAdapter ¶ added in v1.0.7
func NewAdapter(adapterName string, cfg *AdapterConfig) (Adapter, error)
type AdapterCapabilities ¶ added in v1.0.7
type AdapterConfig ¶
type AdapterInfo ¶ added in v1.0.7
type AdapterInfo struct {
Name string
Description string
Capabilities AdapterCapabilities
RequiresSerialPort bool
New func(*AdapterConfig) (Adapter, error)
}
func ListAdapters ¶ added in v1.0.7
func ListAdapters() []AdapterInfo
type CANFrame ¶
type CANFrame struct {
Identifier uint32
Extended bool
RTR bool
Data []byte
FrameType CANFrameType
Timeout time.Duration
}
func NewExtendedFrame ¶ added in v1.0.7
func NewExtendedFrame(identifier uint32, data []byte, frameType CANFrameType) *CANFrame
NewExtendedFrame creates a new CANFrame and copies the data slice
func NewFrame ¶
func NewFrame(identifier uint32, data []byte, frameType CANFrameType) *CANFrame
NewFrame creates a new CANFrame and copies the data slice
func (*CANFrame) ColorString ¶ added in v1.0.7
type CANFrameType ¶
func (*CANFrameType) GetResponseCount ¶
func (c *CANFrameType) GetResponseCount() int
func (*CANFrameType) SetResponseCount ¶
func (c *CANFrameType) SetResponseCount(no int)
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewWithOpts ¶
func (*Client) Send ¶
func (c *Client) Send(identifier uint32, data []byte, f CANFrameType) error
Shortcommand to send a standard 11bit frame
func (*Client) SendAndWait ¶
func (c *Client) SendAndWait(ctx context.Context, frame *CANFrame, timeout time.Duration, identifiers ...uint32) (*CANFrame, error)
Send and wait up to <timeout> for a answer on given identifiers
func (*Client) SendExtended ¶ added in v1.0.7
func (c *Client) SendExtended(identifier uint32, data []byte, f CANFrameType) error
Shortcommand to send a extended 29bit frame
func (*Client) SubscribeChan ¶
func (c *Client) SubscribeChan(ctx context.Context, channel chan *CANFrame, identifiers ...uint32) *Sub
Subscribe to CAN identifiers and return a message channel
func (*Client) SubscribeFunc ¶
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
gmlan/read_vin_from_uec
command
|
|
|
pingpong/client
command
|
|
|
pingpong/server
command
|
|
|
pkg
|
|
|
gmlan
see GMW3110 gmw3110-2010.pdf
|
see GMW3110 gmw3110-2010.pdf |