为了帮助用户提高生产测试效率,我们提供了代为客户拷贝应用程序的服务,在主板出厂之前我们会将用户提交的所有程序和文件拷贝到用户指定的系统目录中,用户拿到主板后可直接装机测试,大大节省了生产测试时间。客户也可参考此方法,在自己的整机生产中实现应用程序及配置文件的自动拷贝。本文以下介绍在ce平台实现应用程序及配置文件自动拷贝的具体步骤。
英创主板处于调试模式启动时,会查询系统的usbdisk根目录下是否有名为autotest.txt的配置文件,如果配置文件存在则会执行文件中指定的exe程序,程序的拷贝正是利用系统的这一功能自动实现的。
实现程序的自动拷贝需要以下几个步骤:
1、编写autotest.txt配置文件
配置文件中需要指定要启动的exe完整路径,同时可配置系统网口1的网络参数,下面是示例配置。
[local_machine]
defaultgateway=192.168.201.19
ipaddress=192.168.201.220
subnetmask=255.255.255.0
[user_exe]
name=\usbdisk\autocfg.exe
parameters=
[system]
store=25
2、编写自动配置程序
配置程序autocft.exe一般需要实现将应用程序拷贝到主板指定目录的功能,同时也可完成用户自定义的一些配置功能,比如增加特定注册表、烧写开机画面等。下面是一些示例代码可供用户参考。
autocopy函数实现将当前执行的配置程序所在目录的全部文件拷贝到系统的nandflash目录中。
dword autocopy( )
{
dword dwresult;
tchar szcurrentdir[max_path];
tchar szlocalfile[max_path];
tchar sznewfile[max_path];
tchar szdisfolder[max_path];
char localfile[max_path];
char newfile[max_path];
int i1, disktype;
dwresult = getmodulefilename( null,szcurrentdir, sizeof( szcurrentdir ) );
if( 0 == dwresult )
{
printf(getmodulefilename failure!\r\n );
return -1;
}
tchar *pch = _tcsrchr( szcurrentdir, '\\' );
*(pch+1) = '\0';
_tcslwr(szcurrentdir);
pch = _tcsstr( szcurrentdir, _t(usb) );
if( null != pch )
{
_tcscpy( szlocalfile, szcurrentdir );
_tcscat( szlocalfile, _t(*.*));
disktype = 1;
getfoldername(disktype, szdisfolder);
handle hfind;
win32_find_data findfiledata;
bool bfind;
hfind = findfirstfile( szlocalfile, &findfiledata);
if(hfind != invalid_handle_value)
{
bfind = true;
while( bfind )
{
if( findfiledata.dwfileattributes != file_attribute_directory )
{
_tcscpy( szlocalfile, szcurrentdir );
_tcscat( szlocalfile, findfiledata.cfilename );
_stprintf(sznewfile, _t(\\%s\\), szdisfolder);
_tcscat( sznewfile, findfiledata.cfilename );
dwresult = copyfile( szlocalfile, sznewfile, false );
memset( localfile, 0, sizeof(localfile));
i1 = wcslen( szlocalfile );
wcstombs( localfile, szlocalfile, i1 );
memset( newfile, 0, sizeof(newfile));
i1 = wcslen( sznewfile );
wcstombs( newfile, sznewfile, i1 );
if( dwresult == 0 )
{
printf(copy %s to %s failure!\r\n, localfile, newfile );
return -1;
}
else
{
printf(copy %s to %s successful!\r\n, localfile, newfile );
}
}
bfind = findnextfile( hfind, &findfiledata );
}
}
findclose( hfind );
}
return 0;
}
// get folder name from register.
// type = 0: sdmemory
// type = 1: nand
// type = 2: usb
// type = 3: emmc
//
void getfoldername( int type, lpwstr szname )
{
hkey hkey = null;
dword dwtype=reg_sz;
dword size=100;
dword ret;
tchar szfolderpath[80];
switch( type )
{
case 0:
_tcscpy( szfolderpath, reg_sdfolder_path );
break;
case 1:
_tcscpy( szfolderpath, reg_nandfolder_path );
break;
case 2:
_tcscpy( szfolderpath, reg_usbfolder_path );
break;
case 3:
_tcscpy( szfolderpath, reg_emmc_path );
break;
default:
return;
}
//get the folder name from registry in case bsp is using non-default name
if (error_success == regcreatekeyex(hkey_local_machine, (lpwstr)szfolderpath,
0, null, reg_option_non_volatile, 0, null, &hkey, null))
{
ret=regqueryvalueex(hkey, lfolder, 0, &dwtype, (byte*)szname, &size);
if (ret!=error_success)
retailmsg(1,(lregqueryvalueex returned error %d dwtype=%d size=%dbufsz=%d\r\n, ret,dwtype,size,sizeof(szname)));
}
if( hkey!=null )
regclosekey(hkey);
return;
}
英创主板支持开机画面在线更新,《wince工控主板在线更新开机画面(2017新版)》中提到的lu程序,用户也可以在配置程序中直接调用实现开机画面的自动更新,下面是利用lu更新u盘目录下usersplash800480.bmp图片的示例代码。
process_information processinfo;
tchar szprogram[] = _t(lu.exe);
tchar szcmdline[100] = _t(usbdisk\\usersplash800480.bmp);
bool result = createprocess( szprogram, szcmdline,null, null, false,create_new_console, null, null, null, &processinfo );
if( result == 0 )
{
//执行失败...
}
3、将autotest.txt放在u盘根目录,同时将配置程序autocft.exe和需要拷贝到主板上的应用程序及文件放在u盘指定目录中。
4、将u盘连接到英创主板,主板在调试模式启动后会自动执行用户指定的配置程序,完成系统配置工作。
系统默认只会执行一次查询autotest.txt启动配置程序的过程,如果希望这个功能总是有效,可在配置程序开始处增加一个清除注册表标志的工作,当系统注册表项hkey_local_machine\emtronix或hkey_local_machine\wstartup下的count等于0时,系统在调试模式下就会查询u盘中的autotest.txt配置文件。下面是count清零代码。
hkey hkey;
dword dwval, dwret;
dword dwtype = reg_dword;
dword dwbuflen = sizeof(dword);
if((dwret = regopenkeyex( hkey_local_machine, _t(emtronix), 0, 0, &hkey)) != error_success)
{
dwret = regopenkeyex( hkey_local_machine, _t(wstartup), 0, 0, &hkey);
}
if(dwret == error_success)
{
dwval = 0;
regsetvalueex(hkey, _t(count), 0, dwtype, (byte*)&dwval, dwbuflen);
regclosekey(hkey); // close registry
}
LED实现白光的方法
监控系统中硬盘录像机连接拼接屏所需要的设备与方案
Huawei Share玩法越来越多,绝不仅仅是传文件
滤波器部分已能实现国产替代?
关于ROM和RAM有哪些常见问题
英创信息技术应用程序及配置文件的生产自动拷贝简介
一体成型电感线圈烧断的原因与解决方法
中芯国际12英寸芯片SN1项目入选重大建设项目清单
MAX14920/MAX14921高精度测量的模拟前端
奔驰的新能源电动卡车发展规划
芯邦科技因公司现发展需要拟申请终止新三板挂牌
四大核心技术 让物联网设备实现一站式上云
三星电子发布可调节生物钟的LED组件
Vishay发布业界最薄的全集成接近和环境光光学传感器
华为阿里年终奖最高500万,让拿到充气娃娃的怎么活?
艾为电子获得ISO 26262汽车功能安全最高等级认证
中兴小鲜5体验 小屏良品时尚青年必备
UWB定位技术赋能化工企业安全生产
服务器虚拟化存储存在什么难题
500元左右的耳机什么好?500元左右的降噪耳机推荐