libsocketcan
v0.0.5
|
Functions | |
int | can_do_start (const char *name) |
can_do_start - start the can interface More... | |
int | can_do_stop (const char *name) |
can_do_stop - stop the can interface More... | |
int | can_do_restart (const char *name) |
can_do_restart - restart the can interface More... | |
int | can_set_restart_ms (const char *name, __u32 restart_ms) |
can_set_restart_ms - set interval of auto restart. More... | |
int | can_set_ctrlmode (const char *name, struct can_ctrlmode *cm) |
can_set_ctrlmode - setup the control mode. More... | |
int | can_set_bittiming (const char *name, struct can_bittiming *bt) |
can_set_bittiming - setup the bittiming. More... | |
int | can_set_bitrate (const char *name, __u32 bitrate) |
can_set_bitrate - setup the bitrate. More... | |
int | can_set_bitrate_samplepoint (const char *name, __u32 bitrate, __u32 sample_point) |
can_set_bitrate_samplepoint - setup the bitrate. More... | |
int | can_get_state (const char *name, int *state) |
can_get_state - get the current state of the device More... | |
int | can_get_restart_ms (const char *name, __u32 *restart_ms) |
can_get_restart_ms - get the current interval of auto restarting. More... | |
int | can_get_bittiming (const char *name, struct can_bittiming *bt) |
can_get_bittiming - get the current bittimnig configuration. More... | |
int | can_get_ctrlmode (const char *name, struct can_ctrlmode *cm) |
can_get_ctrlmode - get the current control mode. More... | |
int | can_get_clock (const char *name, struct can_clock *clock) |
can_get_clock - get the current clock struct. More... | |
int | can_get_bittiming_const (const char *name, struct can_bittiming_const *btc) |
can_get_bittiming_const - get the current bittimnig constant. More... | |
int | can_get_berr_counter (const char *name, struct can_berr_counter *bc) |
can_get_berr_counter - get the tx/rx error counter. More... | |
int | can_get_device_stats (const char *name, struct can_device_stats *cds) |
can_get_device_stats - get the can_device_stats. More... | |
int | can_get_link_stats (const char *name, struct rtnl_link_stats64 *rls) |
can_get_link_statistics - get RX/TX statistics (64 bits version) More... | |
int can_do_restart | ( | const char * | name | ) |
can_do_restart - restart the can interface
name | name of the can device. This is the netdev name, as ifconfig -a shows in your system. usually it contains prefix "can" and the numer of the can line. e.g. "can0" |
This triggers the start mode of the can device.
NOTE:
References can_get_restart_ms(), can_get_state(), and set_link().
int can_do_start | ( | const char * | name | ) |
can_do_start - start the can interface
name | name of the can device. This is the netdev name, as ifconfig -a shows in your system. usually it contains prefix "can" and the numer of the can line. e.g. "can0" |
This starts the can interface with the given name. It simply changes the if state of the interface to up. All initialisation works will be done in kernel. The if state can also be queried by a simple ifconfig.
References set_link().
int can_do_stop | ( | const char * | name | ) |
can_do_stop - stop the can interface
name | name of the can device. This is the netdev name, as ifconfig -a shows in your system. usually it contains prefix "can" and the numer of the can line. e.g. "can0" |
This stops the can interface with the given name. It simply changes the if state of the interface to down. Any running communication would be stopped.
References set_link().
int can_get_berr_counter | ( | const char * | name, |
struct can_berr_counter * | bc | ||
) |
can_get_berr_counter - get the tx/rx error counter.
name | name of the can device. This is the netdev name, as ifconfig -a shows in your system. usually it contains prefix "can" and the numer of the can line. e.g. "can0" |
bc | pointer to the error counter struct.. |
This one gets the current rx/tx error counter from the hardware.
References get_link().
int can_get_bittiming | ( | const char * | name, |
struct can_bittiming * | bt | ||
) |
can_get_bittiming - get the current bittimnig configuration.
name | name of the can device. This is the netdev name, as ifconfig -a shows in your system. usually it contains prefix "can" and the numer of the can line. e.g. "can0" |
bt | pointer to the bittiming struct. |
This one stores the current bittiming configuration.
Please see can_set_bittiming for more information about bit timing.
References get_link().
int can_get_bittiming_const | ( | const char * | name, |
struct can_bittiming_const * | btc | ||
) |
can_get_bittiming_const - get the current bittimnig constant.
name | name of the can device. This is the netdev name, as ifconfig -a shows in your system. usually it contains prefix "can" and the numer of the can line. e.g. "can0" |
btc | pointer to the bittiming constant struct. |
This one stores the hardware dependent bittiming constant. The can_bittiming_const struct consists:
The information in this struct is used to calculate the bus bit timing automatically.
References get_link().
int can_get_clock | ( | const char * | name, |
struct can_clock * | clock | ||
) |
can_get_clock - get the current clock struct.
name | name of the can device. This is the netdev name, as ifconfig -a shows in your system. usually it contains prefix "can" and the numer of the can line. e.g. "can0" |
clock | pointer to the clock struct. |
This one stores the current clock configuration. At the time of writing the can_clock struct only contains information about the clock frequecy. This information is e.g. essential while setting up the bit timing.
References get_link().
int can_get_ctrlmode | ( | const char * | name, |
struct can_ctrlmode * | cm | ||
) |
can_get_ctrlmode - get the current control mode.
name | name of the can device. This is the netdev name, as ifconfig -a shows in your system. usually it contains prefix "can" and the numer of the can line. e.g. "can0" |
cm | pointer to the ctrlmode struct. |
This one stores the current control mode configuration.
Please see can_set_ctrlmode for more information about control modes.
References get_link().
int can_get_device_stats | ( | const char * | name, |
struct can_device_stats * | cds | ||
) |
can_get_device_stats - get the can_device_stats.
name | name of the can device. This is the netdev name, as ifconfig -a shows in your system. usually it contains prefix "can" and the numer of the can line. e.g. "can0" |
bc | pointer to the error counter struct.. |
This one gets the current can_device_stats.
Please see struct can_device_stats for more information.
References get_link().
int can_get_link_stats | ( | const char * | name, |
struct rtnl_link_stats64 * | rls | ||
) |
can_get_link_statistics - get RX/TX statistics (64 bits version)
name | name of the can device. This is the netdev name, as ip link shows in your system. usually it contains prefix "can" and the number of the can line. e.g. "can0" |
rls | pointer to the rtnl_link_stats64 struct which is from if_link.h. |
This one gets the current rtnl_link_stats64. Compares to the rtnl_link_stats, The rtnl_link_stats64 is introduced since linux kernel 2.6. After that the rtnl_link_stats is synchronous with struct rtnl_link_stats64 by truncating each member from 64 bits to 32 bits. actually, the struct rtnl_link_stats is kept for compatibility.
Please see struct rtnl_link_stats64 (/usr/include/linux/if_link.h) for more information.
References get_link().
int can_get_restart_ms | ( | const char * | name, |
__u32 * | restart_ms | ||
) |
can_get_restart_ms - get the current interval of auto restarting.
name | name of the can device. This is the netdev name, as ifconfig -a shows in your system. usually it contains prefix "can" and the numer of the can line. e.g. "can0" |
restart_ms | pointer to store the value. |
This one stores the current interval of auto restarting into the given pointer.
The socketcan framework can automatically restart a device if it is in bus_off in a given interval. This function gets this value in milliseconds. restart_ms == 0 means that autorestarting is turned off.
References get_link().
Referenced by can_do_restart().
int can_get_state | ( | const char * | name, |
int * | state | ||
) |
can_get_state - get the current state of the device
name | name of the can device. This is the netdev name, as ifconfig -a shows in your system. usually it contains prefix "can" and the numer of the can line. e.g. "can0" |
state | pointer to store the state |
This one stores the current state of the can interface into the given pointer. Valid states are:
The first four states is determined by the value of RX/TX error counter. Please see relevant can specification for more information about this. A device in STATE_STOPPED is an inactive device. STATE_SLEEPING is not implemented on all devices.
References get_link().
Referenced by can_do_restart().
int can_set_bitrate | ( | const char * | name, |
__u32 | bitrate | ||
) |
can_set_bitrate - setup the bitrate.
name | name of the can device. This is the netdev name, as ifconfig -a shows in your system. usually it contains prefix "can" and the numer of the can line. e.g. "can0" |
bitrate | bitrate of the can bus |
This is the recommended way to setup the bus bit timing. You only have to give a bitrate value here. The exact bit timing will be calculated automatically. To use this function, make sure that CONFIG_CAN_CALC_BITTIMING is set to y in your kernel configuration. bitrate can be a value between 1000(1kbit/s) and 1000000(1000kbit/s).
References can_set_bittiming().
int can_set_bitrate_samplepoint | ( | const char * | name, |
__u32 | bitrate, | ||
__u32 | sample_point | ||
) |
can_set_bitrate_samplepoint - setup the bitrate.
name | name of the can device. This is the netdev name, as ifconfig -a shows in your system. usually it contains prefix "can" and the numer of the can line. e.g. "can0" |
bitrate | bitrate of the can bus |
sample_point | sample point value |
This one is similar to can_set_bitrate, only you can additionally set up the time point for sampling (sample point) customly instead of using the CIA recommended value. sample_point can be a value between 0 and 999.
References can_set_bittiming().
int can_set_bittiming | ( | const char * | name, |
struct can_bittiming * | bt | ||
) |
can_set_bittiming - setup the bittiming.
name | name of the can device. This is the netdev name, as ifconfig -a shows in your system. usually it contains prefix "can" and the numer of the can line. e.g. "can0" |
bt | pointer to a can_bittiming struct |
This sets the bittiming of the can device. This is for advantage usage. In normal cases you should use can_set_bitrate to simply define the bitrate and let the driver automatically calculate the bittiming. You will only need this function if you wish to define the bittiming in expert mode with fully manually defined timing values. You have to define the bittiming struct yourself. a can_bittiming struct consists of:
to define a customized bittiming, you have to define tq, prop_seq, phase_seg1, phase_seg2 and sjw. See http://www.can-cia.org/index.php?id=88 for more information about bittiming and synchronizations on can bus.
References set_link().
Referenced by can_set_bitrate(), and can_set_bitrate_samplepoint().
int can_set_ctrlmode | ( | const char * | name, |
struct can_ctrlmode * | cm | ||
) |
can_set_ctrlmode - setup the control mode.
name | name of the can device. This is the netdev name, as ifconfig -a shows in your system. usually it contains prefix "can" and the numer of the can line. e.g. "can0" |
cm | pointer of a can_ctrlmode struct |
This sets the control mode of the can device. There are currently the following modes available (each mapped to its own macro):
You have to define the control mode struct yourself. A can_ctrlmode struct is declared as:
You can use mask to select modes you want to control and flags to determine if you want to turn the selected mode(s) on or off. E. g. the following pseudocode will turn the loopback mode on and listenonly mode off:
References set_link().
int can_set_restart_ms | ( | const char * | name, |
__u32 | restart_ms | ||
) |
can_set_restart_ms - set interval of auto restart.
name | name of the can device. This is the netdev name, as ifconfig -a shows in your system. usually it contains prefix "can" and the numer of the can line. e.g. "can0" |
restart_ms | interval of auto restart in milliseconds |
This sets how often the device shall automatically restart the interface in case that a bus_off is detected.
References set_link().