Difference between revisions of "Linux FAQ"
From FriendlyELEC WiKi
Line 9: | Line 9: | ||
===摄像头的设备名称是什么?=== | ===摄像头的设备名称是什么?=== | ||
− | + | ::6410平台: CMOS 摄像头的设备名称为 /dev/video0 ,如果是 USB摄像头,则设备名称为 /dev/video2。 | |
− | ** | + | ::210平台: 代码如下,其中,getCMOSCameraDeviceName函数适用于CMOS和TVP5150摄像头,getUSBCameraDeviceName函数适用于USB摄像头: |
+ | <syntaxhighlight lang="c"> | ||
+ | #define DEVICE_MAX 2 | ||
+ | static const char* getCMOSCameraDeviceName() | ||
+ | { | ||
+ | const char* const devInfoNames[DEVICE_MAX] = { | ||
+ | "/sys/class/video4linux/video0/name" | ||
+ | , "/sys/class/video4linux/video2/name"}; | ||
+ | |||
+ | const char* const devNames[DEVICE_MAX] = { | ||
+ | "/dev/video0" | ||
+ | , "/dev/video2"}; | ||
+ | |||
+ | FILE* f; | ||
+ | int i; | ||
+ | for (i=0; i<DEVICE_MAX;i++) { | ||
+ | f = fopen( devInfoNames[i], "r" ); | ||
+ | if (f == NULL) { | ||
+ | continue; | ||
+ | } | ||
+ | |||
+ | char buff[256] = {0}; | ||
+ | int ret = 0; | ||
+ | |||
+ | if (fread(buff, 1, 255, f) <= 0) { | ||
+ | continue; | ||
+ | } | ||
+ | fclose( f ); | ||
+ | |||
+ | const char* fstr = "s3c-fimc"; | ||
+ | if (strstr(buff, fstr) != NULL) { | ||
+ | break; | ||
+ | } | ||
+ | } | ||
+ | if (i>=DEVICE_MAX) { | ||
+ | return 0; | ||
+ | } | ||
+ | return devNames[i]; | ||
+ | } | ||
+ | |||
+ | static const char* getUSBCameraDeviceName() | ||
+ | { | ||
+ | const char* const devInfoNames[2] = {"/sys/class/video4linux/video0/name" | ||
+ | , "/sys/class/video4linux/video3/name"}; | ||
+ | |||
+ | const char* const devNames[2] = {"/dev/video0" | ||
+ | , "/dev/video3"}; | ||
+ | |||
+ | FILE* f; | ||
+ | int i; | ||
+ | for (i=0; i<2; i++) { | ||
+ | f = fopen( devInfoNames[i], "r" ); | ||
+ | if (f == NULL) { | ||
+ | continue; | ||
+ | } | ||
+ | char buff[256] = {0}; | ||
+ | int ret = 0; | ||
+ | |||
+ | if (fread(buff, 1, 255, f) <= 0) { | ||
+ | continue; | ||
+ | } | ||
+ | fclose( f ); | ||
+ | if (strstr(buff, "s3c-fimc") == NULL) { | ||
+ | break; | ||
+ | } | ||
+ | } | ||
+ | if (i>=2) { | ||
+ | return 0; | ||
+ | } | ||
+ | return devNames[i]; | ||
+ | } | ||
+ | </syntaxhighlight> | ||
===如何开机自动启动我的程序?=== | ===如何开机自动启动我的程序?=== |
Revision as of 02:06, 28 July 2015
Contents
1 如何通过命令行连接WiFi?
输入命令:
`start-wifi wpa2 "ESSID""PASSWORD"`
2 摄像头的设备名称是什么?
- 6410平台: CMOS 摄像头的设备名称为 /dev/video0 ,如果是 USB摄像头,则设备名称为 /dev/video2。
- 210平台: 代码如下,其中,getCMOSCameraDeviceName函数适用于CMOS和TVP5150摄像头,getUSBCameraDeviceName函数适用于USB摄像头:
#define DEVICE_MAX 2 static const char* getCMOSCameraDeviceName() { const char* const devInfoNames[DEVICE_MAX] = { "/sys/class/video4linux/video0/name" , "/sys/class/video4linux/video2/name"}; const char* const devNames[DEVICE_MAX] = { "/dev/video0" , "/dev/video2"}; FILE* f; int i; for (i=0; i<DEVICE_MAX;i++) { f = fopen( devInfoNames[i], "r" ); if (f == NULL) { continue; } char buff[256] = {0}; int ret = 0; if (fread(buff, 1, 255, f) <= 0) { continue; } fclose( f ); const char* fstr = "s3c-fimc"; if (strstr(buff, fstr) != NULL) { break; } } if (i>=DEVICE_MAX) { return 0; } return devNames[i]; } static const char* getUSBCameraDeviceName() { const char* const devInfoNames[2] = {"/sys/class/video4linux/video0/name" , "/sys/class/video4linux/video3/name"}; const char* const devNames[2] = {"/dev/video0" , "/dev/video3"}; FILE* f; int i; for (i=0; i<2; i++) { f = fopen( devInfoNames[i], "r" ); if (f == NULL) { continue; } char buff[256] = {0}; int ret = 0; if (fread(buff, 1, 255, f) <= 0) { continue; } fclose( f ); if (strstr(buff, "s3c-fimc") == NULL) { break; } } if (i>=2) { return 0; } return devNames[i]; }
3 如何开机自动启动我的程序?
修改/etc/init.d/rcS,将/bin/qtopia&这一行改成你想要开机运行的程序。 如果你要开机运行Qt4程序,可参考文档:《Mini6410 Qt4和Qtopia编程开发指南》。 文档下载地址:[1]
4 为什么运行我用Qt4写的程序时无法使用触摸屏?
需要设置相关的环境变量,可参考文档:《Mini6410Qt4和Qtopia编程开发指南》。 文档下载地址:[2]
5 用命令行无法连接WiFi,用图形界面却可以,怎么回事呢?
原因是如果有线网接口是UP状态的,系统会以有线网作为连接,所以在使用WiFi时,先将有线网Down掉,使用如下命令进行: ifconfig eth0 down
===如何在命令行进行3G拨号?
同 Android 平台。