package socketcan

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

CAN frames representing CAN message frames including CAN identifier, payload and time of arrival.

type t

A CAN frame

val max_dlen : int

The maximum payload length in bytes of a CAN frame

val create : Id.t -> ?rtr:bool -> ?error:bool -> ?timestamp:Posix_time.Timespec.t -> Bytes.t -> (t, [> `Exceeded_payload_size ]) Result.result

create i data creates a new CAN frame with CAN-id i and payload data; the payload size must not exceed max_dlen bytes else Result.Error is returned. The extended frame format flag ist set, if the supplied CAN id i is an CAN 2.0B identifier (iff Id.is_eff i = true). The remote transmission request flag and error frame flag are set if rtr and error are set to true respectively. The default timestamp is 0 sec, 0 nsec.

val create_exn : Id.t -> ?rtr:bool -> ?error:bool -> ?timestamp:Posix_time.Timespec.t -> Bytes.t -> t

create_exn i data is identical to create i data but will raise Invalid_argument in case the payload size is exceeded.

val create_data : Id.t -> Bytes.t -> (t, [> `Exceeded_payload_size ]) Result.result

create i p creates a new CAN data frame with CAN-id i and payload p; the payload size must not exceed max_dlen bytes else Result.Error is returned.

val create_data_exn : Id.t -> Bytes.t -> t

create_exn i p is identical to create i p but will raise Invalid_argument in case the payload size is exceeded.

val create_rtr : Id.t -> t

create_rtr i creates a new remote transmission request CAN frame with CAN-id i. The frame does not contain any payload.

val id : t -> Id.t

id f returns the CAN-id of the frame f.

val data : t -> Bytes.t

data f returns the payload of the frame f

val set_data : t -> Bytes.t -> (t, [> `Exceeded_payload_size ]) Result.result

set_data f d returns a new frame with the payload set to d. All other properties of the new frame are identical to f.

val timestamp : t -> Posix_time.Timespec.t

timestamp frame returns the timestamp of the frame frame.

val set_timestamp : t -> Posix_time.Timespec.t -> t

set_timestamp frame timestamp returns a new frame with the timestamp set to timestamp.

val is_rtr : t -> bool

is_rtr frame returns whether the frame frame is a remote transmission request frame.

val set_rtr : t -> t

set_rtr frame returns a new frame with the remote transmission request flag set.

val unset_rtr : t -> t

unset_rtr frame returns a new frame with the remote transmission request flag removed.

val is_error : t -> bool

is_error frame returns whether the frame frame is an error message frame

val set_error : t -> t

set_error frame returns a new frame with the error message flag set.

val unset_error : t -> t

unset_error frame returns a new frame with the error message flag removed.

val is_sff : t -> bool

is_sff frame returns whether the frame frame is a standard frame format frame.

val set_sff : t -> t

set_sff frame returns a new frame with the standard frame format flag set. The CAN identifier will be masked down to sff_mask.

val is_eff : t -> bool

is_eff frame returns whether the frame frame is an extended frame format frame. This is the negation of is_sff: is_eff x = not is_sff x.

val set_eff : t -> t

set_eff frame returns a new frame with the extended frame format flag set.

val to_string : t -> string

to_string f returns a human-readable string representation of the frame f.

val print : t -> unit

print f prints the frame f to stdout in a human-readable fashion.

OCaml

Innovation. Community. Security.