91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 222KB
    文件類型: .bz2
    金幣: 1
    下載: 0 次
    發布日期: 2021-05-25
  • 語言: 其他
  • 標簽: linux??can??

資源簡介

socketcan提供的linux下的CAN網絡工具包 canutils-3.0.2.tar.bz2

資源截圖

代碼片段和文件信息

/*
?*?canutils/canconfig.c
?*
?*?Copyright?(C)?2005?2008?Marc?Kleine-Budde??Pengutronix
?*?Copyright?(C)?2007?Juergen?Beisert??Pengutronix
?*
?*?This?program?is?free?software;?you?can?redistribute?it?and/or?modify
?*?it?under?the?terms?of?the?version?2?of?the?GNU?General?Public?License
?*?as?published?by?the?Free?Software?Foundation
?*
?*?This?program?is?distributed?in?the?hope?that?it?will?be?useful
?*?but?WITHOUT?ANY?WARRANTY;?without?even?the?implied?warranty?of
?*?MERCHANTABILITY?or?FITNESS?FOR?A?PARTICULAR?PURPOSE.?See?the
?*?GNU?General?Public?License?for?more?details.
?*
?*?You?should?have?received?a?copy?of?the?GNU?General?Public?License
?*?along?with?this?program;?if?not?write?to?the?Free?Software
?*?Foundation?Inc.?59?Temple?Place?Suite?330?Boston?MA??02111-1307??USA
?*/

#include?
#include?
#include?
#include?
#include?
#include?
#include?

#include?
#include?
#include?

#ifndef?MIN
#define?MIN(a?b)?((a)?#endif

#define?VALUE_MAX 256
#define?SYSFS_PATH_MAX 256
#define?SYSFS_MNT_PATH “/sys“
#define?SYSFS_PATH_ENV “SYSFS_PATH“

#define?CLASS_NET “/class/net/“

static?char?sysfs_path[SYSFS_PATH_MAX];
static?const?char?*dev;
static?int?version;

enum?can_sysfs_version?{
SV_0
SV_1
SV_MAX
};

enum?can_sysfs_entries?{
SE_BITRATE
SE_MAX
};


static?const?char?*can_sysfs[SV_MAX][SE_MAX]?=?{
[SV_0][SE_BITRATE]?=?“can_bitrate“
[SV_1][SE_BITRATE]?=?“can_bittiming/bitrate“
};

static?void?help(void)
{
fprintf(stderr?“usage:\n\t“
“canconfig??bitrate?{?BR?}\n\t\t“
“BR?:=?\n\t\t“
“canconfig??mode\n“
#if?0
“MODE\n\t\t“
“MODE?:=?{?start?}\n\t“
“canconfig??setentry?[?VALs?]\n\t\t“
“VALs?:=?\n\t\t“
“?bitrate?\n\t\t“
“?tq?\n\t\t“
“?err?\n\t\t“
“?prop_seg?\n\t\t“
“?phase_seg1?\n\t\t“
“?phase_seg2? “?sjw?\n\t\t“
“?sam?<1?|?0>?1?for?3?times?sampling?0?else\n“
#endif
);

exit(EXIT_FAILURE);
}


static?void?make_path(char?*key_path?const?char?*key?size_t?key_path_len)
{
strncpy(key_path?sysfs_path?key_path_len);
strncat(key_path?key?key_path_len);
key_path[key_path_len?-?1]?=?0;
}


static?ssize_t?get_value(const?char*?key?char?*value?size_t?value_len)
{
char?key_path[SYSFS_PATH_MAX];
int?fd;
ssize_t?len;

make_path(key_path?key?sizeof(key_path));

fd?=?open(key_path?O_RDONLY);
if?(fd?==?-1)?{
fprintf(stderr?“opening?‘%s‘?failed:?“
key_path);
perror(NULL);
exit(EXIT_FAILURE);
}

len?=?read(fd?value?value_len?-?1);
close(fd);
if?(len? perror(“read“);
exit(EXIT_FAILURE);
}
value[len]?=?0;

/*?remove?trailing?newline(s)?*/
while?(len?>?0?&&?value[len?-?1]?==?‘\n‘

評論

共有 條評論