Documentation
¶
Index ¶
- Constants
- Variables
- func ListAdapterNames() []string
- func NewGRPCClient() (*grpc.ClientConn, proto.GocanClient, error)
- func NewScantoolVCP(name string) func(cfg *AdapterConfig) (Adapter, error)
- func NewTxbridge(name string) func(cfg *AdapterConfig) (Adapter, error)
- func RegisterAdapter(adapter *AdapterInfo) error
- type ADCCapable
- type Adapter
- func NewAdapter(adapterName string, cfg *AdapterConfig) (Adapter, error)
- func NewCanusbVCP(cfg *AdapterConfig) (Adapter, error)
- func NewELM327(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
- func (base *BaseAdapter) Close()
- func (base *BaseAdapter) Debug(debug string)
- func (base *BaseAdapter) Err() <-chan error
- func (base *BaseAdapter) Error(err error)
- func (base *BaseAdapter) Event() <-chan Event
- func (base *BaseAdapter) Fatal(err error)
- func (base *BaseAdapter) Info(info string)
- func (base *BaseAdapter) Name() string
- func (base *BaseAdapter) Recv() <-chan *CANFrame
- func (base *BaseAdapter) Send() chan<- *CANFrame
- func (base *BaseAdapter) Warn(warn string)
- type CANFrame
- type CANFrameType
- type CanusbVCP
- type Client
- func (c *Client) Adapter() Adapter
- func (c *Client) AdapterName() string
- func (c *Client) Close() (err error)
- func (c *Client) Recv(ctx context.Context, timeout time.Duration, identifiers ...uint32) (*CANFrame, 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) error
- type ELM327
- type Event
- type EventHandler
- type EventType
- type GWClient
- type Just4Trionic
- type Mock
- type OBDXProWifi
- type Opt
- type SLCan
- type ScantoolVCP
- type Subscriber
- type Template
- type TimeoutError
- type Txbridge
- type YACA
Constants ¶
const ( ELM327_OK = "OK\r\r" ELM327_UNKNOWN = "?\r\r" )
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 ListAdapterNames ¶ added in v1.0.7
func ListAdapterNames() []string
func NewGRPCClient ¶ added in v1.0.7
func NewGRPCClient() (*grpc.ClientConn, proto.GocanClient, error)
func NewScantoolVCP ¶ added in v1.0.7
func NewScantoolVCP(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
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
Event() <-chan Event
}
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 NewELM327 ¶ added in v1.0.7
func NewELM327(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 // enable debug logging
Port string // port name or path to dll/so/dylib
PortBaudrate int // port baudrate in bps (only used for serial based adapters)
CANRate float64 // CAN bus rate in kbit/s
CANFilter []uint32 // CAN ID filters
UseExtendedID bool // only used for j2534 when setting upp frame filters
PrintVersion bool // print adapter version info on open
AdditionalConfig map[string]string // Key value pairs for adapter specific configuration
}
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) Debug ¶ added in v1.0.7
func (base *BaseAdapter) Debug(debug string)
Send a debug event
func (*BaseAdapter) Err ¶ added in v1.0.7
func (base *BaseAdapter) Err() <-chan error
Return the error channel for the adapter
func (*BaseAdapter) Error ¶ added in v1.0.7
func (base *BaseAdapter) Error(err error)
Send an error event
func (*BaseAdapter) Event ¶ added in v1.0.7
func (base *BaseAdapter) Event() <-chan Event
func (*BaseAdapter) Fatal ¶ added in v1.0.7
func (base *BaseAdapter) Fatal(err error)
Set a fatal adapter error, meaning communication is broken and cannot continue.
func (*BaseAdapter) Info ¶ added in v1.0.7
func (base *BaseAdapter) Info(info string)
Send an info event
func (*BaseAdapter) Name ¶ added in v1.0.7
func (base *BaseAdapter) Name() string
Name returns the adapter name.
func (*BaseAdapter) Recv ¶ added in v1.0.7
func (base *BaseAdapter) Recv() <-chan *CANFrame
Return the receive channel for the adapter
func (*BaseAdapter) Send ¶ added in v1.0.7
func (base *BaseAdapter) Send() chan<- *CANFrame
Return the send channel for the adapter
func (*BaseAdapter) Warn ¶ added in v1.0.7
func (base *BaseAdapter) Warn(warn string)
Send a warning event
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 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) Recv ¶ added in v1.0.7
func (c *Client) Recv(ctx context.Context, timeout time.Duration, identifiers ...uint32) (*CANFrame, error)
Receive a single CAN frame with specific identifier and timeout
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 ELM327 ¶ added in v1.0.7
type ELM327 struct {
*BaseAdapter
// contains filtered or unexported fields
}
type Event ¶ added in v1.0.7
type EventHandler ¶ added in v1.0.7
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 ScantoolVCP ¶ added in v1.0.7
type ScantoolVCP struct {
*BaseAdapter
// contains filtered or unexported fields
}
func (*ScantoolVCP) Close ¶ added in v1.0.7
func (stn *ScantoolVCP) Close() error
func (*ScantoolVCP) SetFilter ¶ added in v1.0.7
func (stn *ScantoolVCP) SetFilter(filters []uint32) error
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
¶
- adapter.go
- adapter_base.go
- adapter_canusb.go
- adapter_canusb_vcp.go
- adapter_client.go
- adapter_client_linux.go
- adapter_elm327.go
- adapter_just4trionic.go
- adapter_obdx_wifi.go
- adapter_scantool.go
- adapter_scantool_manager.go
- adapter_scantool_vcp.go
- adapter_slcan.go
- adapter_template.go
- adapter_txbridge.go
- adapter_virtual.go
- adapter_yaca.go
- canframe.go
- error.go
- event.go
- gocan.go
- handler.go
- subscriber.go
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
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 |
|
pcan/cmd
command
|
|