Documentation
¶
Index ¶
- Constants
- Variables
- func GetAdapterMap() map[string]*AdapterInfo
- func IsRecoverable(err error) bool
- func List() []string
- func NewGRPCClient() (*grpc.ClientConn, proto.GocanClient, error)
- func NewSTNVCP(name string) func(cfg *AdapterConfig) (Adapter, error)
- func NewTxbridge(name string) func(cfg *AdapterConfig) (Adapter, error)
- func RegisterAdapter(adapter *AdapterInfo) error
- func Unrecoverable(err error) error
- func WriteSerialCommand(port io.Writer, command byte, data []byte) error
- type ADCCapable
- type Adapter
- func NewAdapter(adapterName string, cfg *AdapterConfig) (Adapter, error)
- func NewCanusbVCP(cfg *AdapterConfig) (Adapter, error)
- func NewJust4Trionic(cfg *AdapterConfig) (Adapter, error)
- func NewMock(name string, cfg *AdapterConfig) (Adapter, error)
- func NewOBDXProWifi(cfg *AdapterConfig) (Adapter, error)
- func NewSLCan(cfg *AdapterConfig) (Adapter, error)
- func NewTemplate(name string, cfg *AdapterConfig) (Adapter, error)
- func NewYACA(cfg *AdapterConfig) (Adapter, error)
- type AdapterCapabilities
- type AdapterConfig
- type AdapterInfo
- type BaseAdapter
- type CANFrame
- type CANFrameType
- type CanusbVCP
- type Client
- func (c *Client) Adapter() Adapter
- func (c *Client) AdapterName() string
- func (c *Client) Close() 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) *Subscriber
- func (c *Client) SubscribeChan(ctx context.Context, channel chan *CANFrame, identifiers ...uint32) *Subscriber
- func (c *Client) SubscribeFunc(ctx context.Context, fn func(*CANFrame), identifiers ...uint32) *Subscriber
- func (c *Client) Wait(ctx context.Context, timeout time.Duration, identifiers ...uint32) (*CANFrame, error)
- type GWClient
- type Just4Trionic
- type Mock
- type OBDXProWifi
- type Opts
- type SLCan
- type STNVCP
- type Subscriber
- type Template
- type TimeoutError
- type Txbridge
- type YACA
Constants ¶
const ( OBDLinkSX = "OBDLink SX" OBDLinkEX = "OBDLink EX" STN1170 = "STN1170" STN2120 = "STN2120" )
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 ( Incoming = CANFrameType{Type: 0, Responses: 0} Outgoing = CANFrameType{Type: 1, Responses: 0} ResponseRequired = CANFrameType{Type: 2, Responses: 1} // Used for ELM and STN adapters to signal we want the adapter to wait for a response )
var ( ErrErrorChannelFull = errors.New("error channel full") ErrNillAdapter = errors.New("adapter is nil") ErrDroppedFrame = errors.New("adapter incoming channel full") ErrFramhandlerRegisterSub = errors.New("failed to register subscription, framehandler is full") ErrSendTimeout = errors.New("timeout sending frame") ErrResponsechannelClosed = errors.New("response channel closed") )
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 NewGRPCClient ¶ added in v1.0.7
func NewGRPCClient() (*grpc.ClientConn, proto.GocanClient, error)
func NewSTNVCP ¶ added in v1.0.8
func NewSTNVCP(name string) func(cfg *AdapterConfig) (Adapter, error)
func NewTxbridge ¶ added in v1.0.7
func NewTxbridge(name string) func(cfg *AdapterConfig) (Adapter, error)
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 ADCCapable ¶ added in v1.0.7
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)
func NewCanusbVCP ¶ added in v1.0.7
func NewCanusbVCP(cfg *AdapterConfig) (Adapter, error)
func NewJust4Trionic ¶ added in v1.0.7
func NewJust4Trionic(cfg *AdapterConfig) (Adapter, error)
func NewMock ¶ added in v1.0.7
func NewMock(name string, cfg *AdapterConfig) (Adapter, error)
Create a new Mock adapter used for testing
func NewOBDXProWifi ¶ added in v1.0.7
func NewOBDXProWifi(cfg *AdapterConfig) (Adapter, error)
func NewSLCan ¶ added in v1.0.7
func NewSLCan(cfg *AdapterConfig) (Adapter, error)
func NewTemplate ¶ added in v1.0.7
func NewTemplate(name string, cfg *AdapterConfig) (Adapter, error)
func NewYACA ¶ added in v1.0.7
func NewYACA(cfg *AdapterConfig) (Adapter, error)
type AdapterCapabilities ¶ added in v1.0.7
func (*AdapterCapabilities) String ¶ added in v1.0.7
func (a *AdapterCapabilities) String() string
type AdapterConfig ¶
type AdapterConfig struct {
Debug bool
Port string
PortBaudrate int
CANRate float64
CANFilter []uint32
UseExtendedID bool // only used for j2534 when setting upp frame filters
PrintVersion bool
OnMessage func(string)
MinimumFirmwareVersion string
AdditionalConfig map[string]string // for future use
}
type AdapterInfo ¶ added in v1.0.7
type AdapterInfo struct {
Name string
Description string
RequiresSerialPort bool
Capabilities AdapterCapabilities
New func(*AdapterConfig) (Adapter, error)
}
func ListAdapters ¶ added in v1.0.7
func ListAdapters() []AdapterInfo
func (*AdapterInfo) String ¶ added in v1.0.7
func (a *AdapterInfo) String() string
type BaseAdapter ¶ added in v1.0.7
type BaseAdapter struct {
// contains filtered or unexported fields
}
func NewBaseAdapter ¶ added in v1.0.7
func NewBaseAdapter(name string, cfg *AdapterConfig) BaseAdapter
func (*BaseAdapter) Close ¶ added in v1.0.7
func (base *BaseAdapter) Close()
func (*BaseAdapter) Err ¶ added in v1.0.7
func (base *BaseAdapter) Err() <-chan error
func (*BaseAdapter) Name ¶ added in v1.0.7
func (base *BaseAdapter) Name() string
func (*BaseAdapter) Recv ¶ added in v1.0.7
func (base *BaseAdapter) Recv() <-chan *CANFrame
func (*BaseAdapter) Send ¶ added in v1.0.7
func (base *BaseAdapter) Send() chan<- *CANFrame
func (*BaseAdapter) SetError ¶ added in v1.0.8
func (base *BaseAdapter) SetError(err error)
type CANFrame ¶
type CANFrame struct {
Identifier uint32
Extended bool
RTR bool
Data []byte
FrameType CANFrameType
Timeout uint32
}
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) Bytes ¶ added in v1.0.7
returns the frame as a byte slice, 4 bytes for the identifier, 1 byte for the length and the data if holding more than 8 bytes of data, it will be truncated
func (*CANFrame) ColorString ¶ added in v1.0.7
type CANFrameType ¶
type CanusbVCP ¶ added in v1.0.7
type CanusbVCP struct {
BaseAdapter
// contains filtered or unexported fields
}
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewWithAdapter ¶ added in v1.0.8
Create a new CAN client with given adapter
func NewWithOpts ¶
Create a new CAN client with given adapter and options
func (*Client) AdapterName ¶ added in v1.0.7
Return the name of the underlying adapter
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) Subscribe ¶
func (c *Client) Subscribe(ctx context.Context, identifiers ...uint32) *Subscriber
Subscribe to CAN identifiers and return a message channel
func (*Client) SubscribeChan ¶
func (c *Client) SubscribeChan(ctx context.Context, channel chan *CANFrame, identifiers ...uint32) *Subscriber
Subscribe to CAN identifiers with provided channel
func (*Client) SubscribeFunc ¶
func (c *Client) SubscribeFunc(ctx context.Context, fn func(*CANFrame), identifiers ...uint32) *Subscriber
Subscribe to CAN identifiers with a callback function
type GWClient ¶ added in v1.0.7
type GWClient struct {
BaseAdapter
// contains filtered or unexported fields
}
func NewGWClient ¶ added in v1.0.7
func NewGWClient(adapterName string, cfg *AdapterConfig) (*GWClient, error)
type Just4Trionic ¶ added in v1.0.7
type Just4Trionic struct {
BaseAdapter
// contains filtered or unexported fields
}
func (*Just4Trionic) Close ¶ added in v1.0.7
func (a *Just4Trionic) Close() error
func (*Just4Trionic) SetFilter ¶ added in v1.0.7
func (a *Just4Trionic) SetFilter(filters []uint32) error
type Mock ¶ added in v1.0.7
type Mock struct {
BaseAdapter
}
type OBDXProWifi ¶ added in v1.0.7
type OBDXProWifi struct {
BaseAdapter
// contains filtered or unexported fields
}
func (*OBDXProWifi) Close ¶ added in v1.0.7
func (a *OBDXProWifi) Close() error
func (*OBDXProWifi) SetFilter ¶ added in v1.0.7
func (a *OBDXProWifi) SetFilter(filters []uint32) error
type SLCan ¶ added in v1.0.7
type SLCan struct {
BaseAdapter
// contains filtered or unexported fields
}
type STNVCP ¶ added in v1.0.8
type STNVCP struct {
BaseAdapter
// contains filtered or unexported fields
}
type Subscriber ¶ added in v1.0.7
type Subscriber struct {
// contains filtered or unexported fields
}
func (*Subscriber) Chan ¶ added in v1.0.7
func (s *Subscriber) Chan() <-chan *CANFrame
func (*Subscriber) Close ¶ added in v1.0.7
func (s *Subscriber) Close()
type Template ¶ added in v1.0.7
type Template struct {
BaseAdapter
}
type TimeoutError ¶ added in v1.0.7
func (*TimeoutError) Error ¶ added in v1.0.7
func (e *TimeoutError) Error() string
type Txbridge ¶ added in v1.0.7
type Txbridge struct {
BaseAdapter
// contains filtered or unexported fields
}
type YACA ¶ added in v1.0.7
type YACA struct {
BaseAdapter
// contains filtered or unexported fields
}
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
cangateway
command
|
|
|
testsuite
command
|
|
|
examples
|
|
|
gmlan/read_vin_from_uec
command
|
|
|
list_adapters
command
|
|
|
pingpong/client
command
|
|
|
pingpong/server
command
|
|
|
pkg
|
|
|
gmlan
see GMW3110 gmw3110-2010.pdf
|
see GMW3110 gmw3110-2010.pdf |