大家好,我是极客范的本期栏目编辑小友,现在为大家讲解英创信息技术获取英创Linux主板型号的方法简介问题。
盈创公司十多年来一直专注于嵌入式工控主板的开发,推出了许多不同类型的产品,并与许多客户建立了长期的合作和信任。随着Innolux不断更新产品,推出性能越来越好的新产品,很多客户也在更新产品,推出新项目。
经过长时间的积累,很多客户在很多项目中都使用了Innolux的不同类型的板材。为了方便客户管理应用程序,Innolux编制了一套方法,方便客户识别板卡型号。通过这种方法,客户可以集成多个项目的程序,通过一个管理程序判断板卡,然后进行相应的操作,非常简单方便。
客户只需读取主板文件系统中的文件/etc/主机名。关于Innolux主要产品型号与主机名文件的对应关系,请参考下表:
纸板模型
主机名文件
Em9x60系列主板。
EM9X60
Em928x系列主板。
EM9280
Em335x系列主板。
EM335X
Esm335x系列主板。
ESM335X
Esm6800板。
ESM6800
Esm6802板。
ESM6802
以下是判断卡型号并打印出来的简单套路,可供有需要的客户参考:
#包括
#包括
#包括
#包括
枚举类型{em9x60=1,em928x,em335x,esm335x,es m 6800 };
/*从/etc/hostname *获取boadrtype
int main(int argc,char *argv[])
{
FILE * fp
char buf[50];
int board type=0;
fp=fopen('/etc/hostname ',' Rb ');
if(fp==空)
{
perror('/etc/hostname ');
返回errno
}
fread(buf,sizeof(char),50,FP);
if(strtr(buf,' EM9X60') 0)
boardtype=em9x60
else if(strtr(buf,' EM9280') 0)
boardtype=em928x
否则如果
(strstr(buf,"EM335X") >0)boardtype = em335x;
else if(strstr(buf,"ESM335X") >0)
boardtype = esm335x;
else if(strstr(buf,"ESM6800") >0)
boardtype = esm6800;
fclose(fp);
switch(boardtype)
{
case em9x60:
printf("the boardtype is EM9x60\n");
break;
case em928x:
printf("the boardtype is EM928x\n");
break;
case em335x:
printf("the boardtype is EM335x\n");
break;
case esm335x:
printf("the boardtype is ESM335x\n");
break;
case esm6800:
printf("the boardtype is ESM680x\n");
break;
default:
printf("the boardtype is unknow, please check the platform!\n");
break;
}
return 0;
}
英创公司十余年来都专注于嵌入式工控主板的开发,推出了很多不同型号的产品,也和许多客户建立了长期的合作和信任。随着英创公司不断的对产品进行更新,推出性能越来越好的新产品,很多客户也对自己的产品进行更新,并且推出新的项目。
经过长时间的累积,已经有许多客户的多个项目使用了英创公司不同型号的板卡,为了让客户更方便的管理应用程序,英创公司整理了一个方便客户识别板卡型号的方法,通过这个方法,客户可以将多个项目的程序整合起来,通过一个管理程序,对板卡进行判断,然后执行相应的操作,十分简单和方便。
客户只需要读取板卡文件系统中的/etc/hostname这个文件就可以了,英创公司目前主要的产品型号和hostname文件的对应可以参考下面的表格:
板卡型号hostname文件em9x60系列板卡EM9X60em928x系列板卡EM9280em335x系列板卡EM335Xesm335x系列板卡ESM335Xesm6800板卡ESM6800esm6802板卡ESM6802下面的是一个简单的例程,判断板卡型号并打印出来,可以供需要的客户参考:
#include
#include
#include
#include
enum type{em9x60 = 1, em928x, em335x, esm335x, esm6800};
int main(int argc, char *argv[])
{
FILE *fp;
char buf[50];
int boardtype = 0;
fp = fopen("/etc/hostname","rb");
if(fp == NULL)
{
perror("/etc/hostname");
return errno;
}
fread( buf, sizeof(char), 50, fp );
if(strstr(buf,"EM9X60") >0)
boardtype = em9x60;
else if(strstr(buf,"EM9280") >0)
boardtype = em928x;
else if(strstr(buf,"EM335X") >0)
boardtype = em335x;
else if(strstr(buf,"ESM335X") >0)
boardtype = esm335x;
else if(strstr(buf,"ESM6800") >0)
boardtype = esm6800;
fclose(fp);
switch(boardtype)
{
case em9x60:
printf("the boardtype is EM9x60\n");
break;
case em928x:
printf("the boardtype is EM928x\n");
break;
case em335x:
printf("the boardtype is EM335x\n");
break;
case esm335x:
printf("the boardtype is ESM335x\n");
break;
case esm6800:
printf("the boardtype is ESM680x\n");
break;
default:
printf("the boardtype is unknow, please check the platform!\n");
break;
}
return 0;
}
.dfma { position: relative; width: 1000px; margin: 0 auto; } .dfma a::after { position: absolute; left: 0; bottom: 0; width: 30px; line-height: 1.4; text-align: center; background-color: rgba(0, 0, 0, .5); color: #fff; font-size: 12px; content:"广告"; } .dfma img { display: block; }