Linux API2014. 9. 2. 08:08

'Linux API' 카테고리의 다른 글

lirc - linux IR Remote control  (0) 2015.03.31
vaapi vdpau uvd  (6) 2015.03.26
linux 최대 thread 갯수  (0) 2015.01.22
getopt() / getopt_long()  (0) 2014.11.19
timeval, gettimeofday()  (0) 2013.08.20
Posted by 구차니
Linux API2013. 8. 20. 19:03

clock_gettime() 사용 추천

 

SVr4, 4.3BSD. POSIX.1-2001 describes gettimeofday() but not settimeofday(). POSIX.1-2008 marks gettimeofday() as obsolete, recommending the use of clock_gettime(2) instead.

[링크 : https://man7.org/linux/man-pages/man2/gettimeofday.2.html]

[링크 : https://man7.org/linux/man-pages/man2/clock_gettime.2.html]

[링크 : https://minimonk.tistory.com/5700]

---

time_t의 경우 1초 단위로 밖에 시간을 얻을수가 없는데
gettimeofday()를 통해 timeval 구조체로 값을 받으면
ms 단위로 시간을 잴 수 있다.

clock_getres 하면 ns 단위로 해당 시스템의 시간 정밀도를 받을수 있다는데
아무리 시스템이 빨라져도 ns 단위로 타이머를 받기 힘들지도 모르겠다..

[링크 : http://linux.die.net/man/2/clock_getres]
[링크 : http://linux.die.net/man/2/gettimeofday]
[링크 : http://forum.falinux.com/zbxe/index.php?document_srl=507542]

'Linux API' 카테고리의 다른 글

lirc - linux IR Remote control  (0) 2015.03.31
vaapi vdpau uvd  (6) 2015.03.26
linux 최대 thread 갯수  (0) 2015.01.22
getopt() / getopt_long()  (0) 2014.11.19
공유메모리  (0) 2014.09.02
Posted by 구차니
Linux API/joystick2012. 2. 5. 11:36
조이스틱 관련 구조체 및 매크로 내용
우분투 기준 /usr/include/linux/joystick.h 에 존재함.

#ifndef _LINUX_JOYSTICK_H
#define _LINUX_JOYSTICK_H

/*
 *  Copyright (C) 1996-2000 Vojtech Pavlik
 *
 *  Sponsored by SuSE
 */

/*
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or 
 * (at your option) any later version.
 * 
 * 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
 * 
 * Should you need to contact me, the author, you can do so either by
 * e-mail - mail your message to vojtech@suse.cz, or by paper mail:
 * Vojtech Pavlik, Ucitelska 1576, Prague 8, 182 00 Czech Republic
 */

#include "linux/types.h"
#include "linux/input.h"

/*
 * Version
 */

#define JS_VERSION		0x020100

/*
 * Types and constants for reading from /dev/js
 */

#define JS_EVENT_BUTTON		0x01	/* button pressed/released */
#define JS_EVENT_AXIS		0x02	/* joystick moved */
#define JS_EVENT_INIT		0x80	/* initial state of device */

struct js_event {
	__u32 time;	/* event timestamp in milliseconds */
	__s16 value;	/* value */
	__u8 type;	/* event type */
	__u8 number;	/* axis/button number */
};

/*
 * IOCTL commands for joystick driver
 */

#define JSIOCGVERSION		_IOR('j', 0x01, __u32)				/* get driver version */

#define JSIOCGAXES		_IOR('j', 0x11, __u8)				/* get number of axes */
#define JSIOCGBUTTONS		_IOR('j', 0x12, __u8)				/* get number of buttons */
#define JSIOCGNAME(len)		_IOC(_IOC_READ, 'j', 0x13, len)			/* get identifier string */

#define JSIOCSCORR		_IOW('j', 0x21, struct js_corr)			/* set correction values */
#define JSIOCGCORR		_IOR('j', 0x22, struct js_corr)			/* get correction values */

#define JSIOCSAXMAP		_IOW('j', 0x31, __u8[ABS_MAX + 1])		/* set axis mapping */
#define JSIOCGAXMAP		_IOR('j', 0x32, __u8[ABS_MAX + 1])		/* get axis mapping */
#define JSIOCSBTNMAP		_IOW('j', 0x33, __u16[KEY_MAX - BTN_MISC + 1])	/* set button mapping */
#define JSIOCGBTNMAP		_IOR('j', 0x34, __u16[KEY_MAX - BTN_MISC + 1])	/* get button mapping */

/*
 * Types and constants for get/set correction
 */

#define JS_CORR_NONE		0x00	/* returns raw values */
#define JS_CORR_BROKEN		0x01	/* broken line */

struct js_corr {
	__s32 coef[8];
	__s16 prec;
	__u16 type;
};

/*
 * v0.x compatibility definitions
 */

#define JS_RETURN		sizeof(struct JS_DATA_TYPE)
#define JS_TRUE			1
#define JS_FALSE		0
#define JS_X_0			0x01
#define JS_Y_0			0x02
#define JS_X_1			0x04
#define JS_Y_1			0x08
#define JS_MAX			2

#define JS_DEF_TIMEOUT		0x1300
#define JS_DEF_CORR		0
#define JS_DEF_TIMELIMIT	10L

#define JS_SET_CAL		1
#define JS_GET_CAL		2
#define JS_SET_TIMEOUT		3
#define JS_GET_TIMEOUT		4
#define JS_SET_TIMELIMIT	5
#define JS_GET_TIMELIMIT	6
#define JS_GET_ALL		7
#define JS_SET_ALL		8

struct JS_DATA_TYPE {
	__s32 buttons;
	__s32 x;
	__s32 y;
};

struct JS_DATA_SAVE_TYPE_32 {
	__s32 JS_TIMEOUT;
	__s32 BUSY;
	__s32 JS_EXPIRETIME;
	__s32 JS_TIMELIMIT;
	struct JS_DATA_TYPE JS_SAVE;
	struct JS_DATA_TYPE JS_CORR;
};

struct JS_DATA_SAVE_TYPE_64 {
	__s32 JS_TIMEOUT;
	__s32 BUSY;
	__s64 JS_EXPIRETIME;
	__s64 JS_TIMELIMIT;
	struct JS_DATA_TYPE JS_SAVE;
	struct JS_DATA_TYPE JS_CORR;
};


#endif /* _LINUX_JOYSTICK_H */


실험적으로 소스를 짜서 해보니
버튼은 type 1
value는 0(눌리지 않음) 1(눌림)
number는 버튼 번호(1번 버튼은 0번 부터 시작)

X/Y/Z 축은 type 2
좌우는 number 0
앞뒤는 number 1
쓰로틀은 number 2
러더는 number 3 
햇좌우 number 5
햇앞뒤 number 6
 
값이 변하기 전에는 새로운 값은 읽히지 않는 듯 하고,
그런 이유로 예제 파일이 멀티쓰레드로 구성이 된 것으로 생각된다. 

'Linux API > joystick' 카테고리의 다른 글

linux force feedback  (0) 2022.06.15
리눅스에서 조이스틱 값 읽어오기  (0) 2012.02.04
Posted by 구차니
Linux API/usb2012. 2. 4. 18:24
심심(?)해서 USB 조이스틱 2개를 연결해서 본 목록

$ cat /proc/bus/usb/devices 
$ cat /sys/kernel/debug/usb/devices
에는 토폴로지 별로 상세하게 출력되고 

lsusb를 통해서도 볼수는 있는데
$ lsusb -d 12bd:a02f -v 식으로 하나의 장치만을 자세히 볼수도 있다.
$ lsusb
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 005: ID 0583:206f Padix Co., Ltd (Rockfire) 
Bus 003 Device 004: ID 12bd:a02f  
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub


$ tree -a /dev/bus
/dev/bus
`-- usb
    |-- 001
    |   `-- 001
    |-- 002
    |   `-- 001
    |-- 003
    |   |-- 001
    |   |-- 004
    |   `-- 005
    |-- 004
    |   `-- 001
    `-- 005
        `-- 001

6 directories, 7 files 


















 
$ tree -a /proc/bus
/proc/bus
|-- input
|   |-- devices
|   `-- handlers
|-- pccard
|   `-- drivers
`-- pci
    |-- 00
    |   |-- 00.0
    |   |-- 02.0
    |   |-- 02.1
    |   |-- 1b.0
    |   |-- 1c.0
    |   |-- 1c.2
    |   |-- 1d.0
    |   |-- 1d.1
    |   |-- 1d.2
    |   |-- 1d.3
    |   |-- 1d.7
    |   |-- 1e.0
    |   |-- 1f.0
    |   |-- 1f.1
    |   |-- 1f.2
    |   `-- 1f.3
    |-- 02
    |   `-- 00.0
    |-- 06
    |   |-- 00.0
    |   |-- 00.2
    |   |-- 00.3
    |   |-- 00.4
    |   `-- 02.0
    `-- devices

6 directories, 26 files 
$ tree -a /sys/kernel/debug/usb/
/sys/kernel/debug/usb/
|-- devices
`-- usbmon
    |-- 0s
    |-- 0u
    |-- 1s
    |-- 1t
    |-- 1u
    |-- 2s
    |-- 2t
    |-- 2u
    |-- 3s
    |-- 3t
    |-- 3u
    |-- 4s
    |-- 4t
    |-- 4u
    |-- 5s
    |-- 5t
    `-- 5u

1 directory, 18 files 












 

$ tree -a /dev/input
/dev/input
|-- by-id
|   |-- usb-0583_USB_2-axis_8-button_gamepad-event-joystick -> ../event10
|   |-- usb-0583_USB_2-axis_8-button_gamepad-joystick -> ../js1
|   |-- usb-12bd_5-Axis_12-Button_with_POV-event-joystick -> ../event6
|   `-- usb-12bd_5-Axis_12-Button_with_POV-joystick -> ../js0
|-- by-path
|   |-- pci-0000:00:1d.1-usb-0:1:1.0-event-joystick -> ../event6
|   |-- pci-0000:00:1d.1-usb-0:1:1.0-joystick -> ../js0
|   |-- pci-0000:00:1d.1-usb-0:2:1.0-event-joystick -> ../event10
|   |-- pci-0000:00:1d.1-usb-0:2:1.0-joystick -> ../js1
|   |-- platform-i8042-serio-0-event-kbd -> ../event5
|   |-- platform-i8042-serio-2-event-mouse -> ../event8
|   `-- platform-i8042-serio-2-mouse -> ../mouse1
|-- event0
|-- event1
|-- event10
|-- event2
|-- event3
|-- event4
|-- event5
|-- event6
|-- event7
|-- event8
|-- event9
|-- js0
|-- js1
|-- mice
|-- mouse0
`-- mouse1

2 directories, 27 files 

아무튼, 개략적으로 USB 연결시 확인해야 할 경로는 위에 녀석들 뿐이려나?

[링크 : http://docs.blackfin.uclinux.org/kernel/generated/usb/index.html] << USB API
[링크 : http://www.linux-usb.org/USB-guide/book1.html]
Posted by 구차니
Linux API/joystick2012. 2. 4. 14:37
CCTV(PTZ) 업체에 있다 보니 리눅스에서도 조이스틱을 이용해서
컨트롤러를 대체할수 있을까 라는 생각에 조이스틱 관련 API를 찾아보는데
의외로 단순한 구조 같은 느낌..

요즘에는 USB로도 많이 쓰니 USB목록에서 장치명을 찾아서 열거하는 것도 필요할 듯 하고
아무튼 중요한건 js_event 구조체 이녀석인듯.
int fd = open ("/dev/js0", O_RDONLY);
struct js_event e;
read (fd, &e, sizeof(struct js_event));

struct js_event {
__u32 time;     /* event timestamp in milliseconds */
__s16 value;    /* value */
__u8 type;      /* event type */
__u8 number;    /* axis/button number */
}; 

[링크 : http://www.mjmwired.net/kernel/Documentation/input/joystick-api.txt] 3.2 kernel
[링크 :  http://archives.seul.org/linuxgames/Aug-1999/msg00107.html] 2.2 kernel

----
curse.h가 없다고 에러날 경우는 아래와 같이 설치해주고
$ sudo apt-get install libncurses5-dev  

소스는 이런식으로 수정하고 컴파일을 하면된다.
#define JOY_DEV "/dev/input/js0"  

#include "pthread.h"
#include "sys/timeb.h"
#include "curses.h"
#include "fcntl.h"
#include "linux/joystick.h"

#define NUM_THREADS	3
#define JOY_DEV		"/dev/input/js0"
#define HZ				12

const char FILENAME[] = "./joystickLog.out";
char axisDesc[15][5] = {"X", "Y", "Z", "R", "A", "B", "C", "D", "E", "F", "G", "H", "I" };
char numAxis[20], numButtons[20], value[20][20], timeSec[20], timeMilli[20];
int num_of_axis;

void write_to_log(){
	sleep(1);
	int cnt;
	FILE * daFile;
	daFile = fopen(FILENAME, "w+");

//	WRITE A HEADER ON THE OUPUT FILE
	fprintf(daFile, "#,");
	for(cnt = 0; cnt < num_of_axis; cnt++)
		if(cnt < num_of_axis -1)	fprintf(daFile, "%s,", axisDesc[cnt]);
		else								fprintf(daFile, "%s", axisDesc[cnt]);
	fprintf(daFile, "\r\n");

	while(1){
		fprintf(daFile, "%s.%s, ", timeSec, timeMilli);
		for(cnt = 0; cnt < num_of_axis; cnt++){
			if(cnt < num_of_axis -1)	fprintf(daFile, "%s, ", value[cnt]);
			else								fprintf(daFile, "%s ", value[cnt]);
		}
		fprintf(daFile, "\r\n");
		usleep(83333);
	}
	
	fprintf(daFile, "%s.%s Len = %d ", timeSec, timeMilli,strlen(timeMilli));

	fprintf(daFile, "\r\n");
	fflush(daFile);
}

void write_to_screen(){
	struct timeb seconds;
	int cnt, joy_fd, *axis=NULL, num_of_buttons=0, x;
	char *button=NULL, name_of_joystick[80];
	struct js_event js;
	time_t theTime;

	wmove(stdscr, 8, 0);
	addstr("Type \"q\" to quit.\n");

	if( ( joy_fd = open( JOY_DEV , O_RDONLY)) == -1 ){
		wmove(stdscr, 3,0);
		addstr( "Couldn't open joystick " );
		addstr( JOY_DEV );
		wmove(stdscr, 10,0);
		while(1)usleep(16666);
	}

	ioctl( joy_fd, JSIOCGAXES, &num_of_axis );				//	GET THE NUMBER OF AXIS ON JS
	ioctl( joy_fd, JSIOCGBUTTONS, &num_of_buttons );		//	GET THE NUMBER OF BUTTONS ON THE JS
	ioctl( joy_fd, JSIOCGNAME(80), &name_of_joystick );	//	GET THE NAME OF THE JS

	axis = (int *) calloc( num_of_axis, sizeof( int ) );
	button = (char *) calloc( num_of_buttons, sizeof( char ) );

	sprintf(numAxis, "%d", num_of_axis);
	sprintf(numButtons, "%d", num_of_buttons);

	wmove(stdscr, 0,0);
	addstr("Joystick detected: ");

	wmove(stdscr, 0, 19);
	addstr(name_of_joystick);

	wmove(stdscr, 1, 0);
	addstr("Number of axis   :");

	wmove(stdscr, 1, 19);
	addstr(numAxis);
	
	wmove(stdscr, 2, 0);
	addstr("Number of buttons:");

	wmove (stdscr, 2, 19);
	addstr(numButtons);

//	CHANGE THE STATUS FLAG OF THE FILE DESCRIPTOR TO NON-BLOCKING MODE
	fcntl( joy_fd, F_SETFL, O_NONBLOCK );   

	while( 1 ){
		usleep(16666);
	
	//	READ THE JOYSTICK STATE, IT WILL BE RETURNED IN THE JS_EVENT STRUCT
		read(joy_fd, &js, sizeof(struct js_event));

	//	GET THE NUMBER OF SECONDS SINCE EPOCH
		ftime(&seconds);
		theTime = time(NULL);
		sprintf(timeSec, "%d", seconds.time);						
		sprintf(timeMilli, "%d", seconds.millitm);
               
	//	CHECK THE EVENT
		switch (js.type & ~JS_EVENT_INIT){
			case JS_EVENT_AXIS:
				axis   [ js.number ] = js.value;
				break;
			case JS_EVENT_BUTTON:
				button [ js.number ] = js.value;
				break;
		}
		//	ADD LEADING 0'S TO THE MILLISECOND STRING (IF NECESSARY)
			char temp[10] = "";
			while(strlen(temp) < (3 - strlen(timeMilli)))
				strcat(temp, "0");
			strcat(temp,timeMilli);
			strcpy(timeMilli, temp);

		//	PRINT THE RESULTS
			wmove(stdscr, 4, 0);
			for(cnt = 0; cnt < num_of_axis; cnt++)
				addstr("            ");
			for(cnt = 0; cnt < num_of_axis && cnt < 13; cnt++){
				sprintf(value[cnt], "%d", axis[cnt]);
				wmove(stdscr, 4, cnt * 10);
				addstr(axisDesc[cnt]);
				addstr(": ");
				wmove(stdscr, 4, (cnt * 10) + 2);
				addstr(value[cnt]);
			}
			
			wmove(stdscr, 6, 0);
			addstr(timeSec);
			wmove(stdscr, 6,10);
			addstr(".");
			wmove(stdscr, 6, 11);
			addstr(timeMilli);
			wmove(stdscr, 6, 15);
			addstr("=");
			wmove(stdscr, 6, 17);
			addstr(ctime(&theTime));
                       
			wmove(stdscr, 10, 0);
			refresh();
	}
}

void *ThreadProcs(void *threadid){
	int thread_id = (int)threadid;
	
	if(thread_id == 0){
		write_to_screen();
	}
	
	if(thread_id == 1){
	//	THIS THREAD WILL MAKE THE PROGRAM EXIT
		int ch;
		nodelay(stdscr, TRUE);				//	SETUP NON BLOCKING INPUT
		while(1) {
			if ((ch = getch()) == ERR) usleep(16666);		//	USER HASN'T RESPONDED
			else if( ch == 'q'){			
				endwin();
				exit(0);			//	QUIT ALL THREADS
			}
		}
	}
	if(thread_id == 2){
		write_to_log();
	}
}

int main(int argc, char *argv[]){
	initscr(); 									//	INIT THE SCREEN FOR CURSES
	pthread_t threads[NUM_THREADS];
	int rc, t;
	for(t = 0; t < NUM_THREADS; t++){	//	MAKE 2 NEW THREADS
		rc = pthread_create(&threads[t], NULL, ThreadProcs, (void *)t);
		if (rc){
			printf("ERROR; return code from pthread_create() is %d\n", rc);
			exit(-1);pthread_exit(NULL);
		}
	}
	
	for(t = 0; t < NUM_THREADS; t++)
		pthread_join(threads[t], NULL);		//	WAIT FOR THREADS TO EXIT OR IT WILL RACE TO HERE.

	endwin();
	return 0;
}


[링크 : http://www.linuxquestions.org/questions/programming-9/joystick-347292/]
 + [링크 : http://sukwoo.blogspot.com/2008/07/ubuntu-804-ncurses.html]
---
[링크 : http://msdn.microsoft.com/en-us/library/windows/desktop/dd743596(v=vs.85).aspx] << 윈도우용

'Linux API > joystick' 카테고리의 다른 글

linux force feedback  (0) 2022.06.15
linux/joystick.h 파일  (0) 2012.02.05
Posted by 구차니
Linux API/network2011. 11. 7. 23:30
아따 여러단계로 해놨네 -_-
route 라던가 ifconfig 등의 소스를 받을수 있는 링크이다.
binutils에 속해있을 줄 알았는데 별도의 소스일줄이야...

[링크 : http://net-tools.berlios.de/]
[링크 : http://net-tools.sourceforge.net/]
[링크 : http://sourceforge.net/projects/net-tools/]

'Linux API > network' 카테고리의 다른 글

linux socket 관련  (0) 2015.01.22
멀티캐스트 되는지 여부 확인  (0) 2014.11.21
INADDR_ANY/INADDR_BROADCAST/INADDR_NONE 매크로  (0) 2011.09.29
hton(), ntoh()  (0) 2011.09.26
netstat 에서 0.0.0.0의 의미  (2) 2009.12.07
Posted by 구차니
Linux API/network2011. 9. 29. 18:05
/usr/include/netinet/in.h

176 /* Address to accept any incoming messages.  */
177 #define INADDR_ANY      ((in_addr_t) 0x00000000)
178 /* Address to send to all hosts.  */
179 #define INADDR_BROADCAST    ((in_addr_t) 0xffffffff)
180 /* Address indicating an error return.  */
181 #define INADDR_NONE     ((in_addr_t) 0xffffffff) 

hton() 과 같은 변환없이 사용해도 되는 매크로인데
255.255.255.255(BROADCAST/NONE) 혹은 0.0.0.0(ANY) 으로 치환이 된다.

'Linux API > network' 카테고리의 다른 글

멀티캐스트 되는지 여부 확인  (0) 2014.11.21
net tools 소스코드  (0) 2011.11.07
hton(), ntoh()  (0) 2011.09.26
netstat 에서 0.0.0.0의 의미  (2) 2009.12.07
ioctl을 이용한 정보수집  (0) 2009.11.30
Posted by 구차니
Linux API/network2011. 9. 26. 15:38
프로그래밍을 하다보면 짜증나는 것 중에 하나가 바로 이넘의 Byte Order이다.
Intel CPU가 Little Endian 이다 보니 Big Endian 과 유사한 비트 스트림의 경우에는
순서를 죄다 뒤집어주어야 한다. (어셈블러로 그냥 이런 명령어 하나 좀 만들어 주지 -_-)

uint32_t htonl(uint32_t hostlong);
uint16_t htons(uint16_t hostshort);
uint32_t ntohl(uint32_t netlong);
uint16_t ntohs(uint16_t netshort);

The htonl() function converts the unsigned integer hostlong from host byte order to network byte order.
The htons() function converts the unsigned short integer hostshort from host byte order to network byte order.

The ntohl() function converts the unsigned integer netlong from network byte order to host byte order.
The ntohs() function converts the unsigned short integer netshort from network byte order to host byte order.

On the i80x86 the host byte order is Least Significant Byte first, whereas the network byte order, as used on the Internet, is Most Significant Byte first.
 
[링크 : http://linux.die.net/man/3/htonl

머.. 정리 하자면
hton 은 ip 주소를 보낼때
ntoh 는 ip 주소를 받았을때 사용하면 될듯? 
Posted by 구차니
Linux API/network2009. 12. 7. 13:42
0.0.0.0 은 간단하게 all allow의 의미라고 한다.







MS 넘들은 뻑하면 "의도된 설계입니다"
이 한마디로 구렁이 담 넘어 가듯 넘어간단 말이야 ㄱ-

The Winsock application that is listening on the designated port was written so that it binds to any local IP address by using INADDR_ANY. This means that the application will listen to all local interfaces and you can connect to the port of any of them. This is why netstat -an shows IP address 0.0.0.0 listening on the port.

[링크 : http://support.microsoft.com/?scid=kb%3Ben-us%3B175952&x=6&y=11]



-------------
$ netstat -an | more
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address               Foreign Address             State
tcp        0      0 0.0.0.0:2049                0.0.0.0:*                   LISTEN
tcp        0      0 0.0.0.0:674                 0.0.0.0:*                   LISTEN
tcp        0      0 0.0.0.0:139                 0.0.0.0:*                   LISTEN

$ netstat -a | more
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address               Foreign Address             State
tcp        0      0 *:nfs                       *:*                         LISTEN
tcp        0      0 *:acap                      *:*                         LISTEN
tcp        0      0 *:netbios-ssn               *:*                         LISTEN

리눅스 상에서는 0.0.0.0 은 *로 표시 되기도 한다.
(-n 옵션은 numeric하게 출력할지 아니면 /etc/services 의 문자열로 출력할지를 결정하는 옵션이다)

'Linux API > network' 카테고리의 다른 글

INADDR_ANY/INADDR_BROADCAST/INADDR_NONE 매크로  (0) 2011.09.29
hton(), ntoh()  (0) 2011.09.26
ioctl을 이용한 정보수집  (0) 2009.11.30
termios 구조체를 이용한 자국반향(echo) 제어  (0) 2009.08.27
canonical / non-canonical  (0) 2009.08.27
Posted by 구차니
Linux API/v4l2009. 12. 6. 19:41
  [CAMEL PC-100 : http://blog.danawa.com/prod/?prod_c=956003]
  [더불정보기술 X-LUK DBC-UP : http://blog.danawa.com/prod/?prod_c=911980]

위에 두녀석을 다시 꼽아 보니 둘다 video0가 생성이 된다.
CAMEL PC-100은 내장 마이크/사운드 장치가 있고
X-LUK DBC-UP은 내장 마이크 조차 없는 녀석이다(단지 PC용 monitor 프로그램이 있어서 산것일뿐 ㄱ-)

아무튼 /dev를 비교해보니 아래와 같이 추가가 되었다.

 CAMEL PC-10  더불정보기술 X-LUK DBC-UP
/dev
crw-rw----+ 1 root audio    14,  20 2009-12-06 19:22 audio1
crw-rw----+ 1 root audio    14,  19 2009-12-06 19:22 dsp1
crw-rw----+ 1 root audio    14,  16 2009-12-06 19:22 mixer1
drwxr-xr-x  4 root root          80 2009-12-06 19:22 v4l
crw-rw----+ 1 root video    81,   0 2009-12-06 19:22 video0

~$ tree /dev/v4l
/dev/v4l
|-- by-id
|   `-- usb-ARKMICRO_USB2.0_PC_CAMERA-video-index0 -> ../../video0
`-- by-path
    `-- pci-0000:00:10.4-usb-0:3:1.0-video-index0 -> ../../video0
/dev



drwxr-xr-x  4 root root          80 2009-12-06 19:30 v4l
crw-rw----+ 1 root video    81,   0 2009-12-06 19:30 video0

$ tree /dev/v4l
/dev/v4l
|-- by-id
|   `-- usb-Vimicro_Corp._PC_Camera-video-index0 -> ../../video0
`-- by-path
    `-- pci-0000:00:10.1-usb-0:1:1.0-video-index0 -> ../../video0

아무튼, video0 장치는 둘다 생기고, video4linux 장비로 인식을 한다. (ffmpeg이 왜 안되는겨 ㅠ.ㅠ)


CAMEL PC-10
$ ffmpeg -y -f video4linux -r 30 -s 320x240 -i /dev/video0 http://localhost:8090/feed1.ffm
FFmpeg version SVN-r19352-4:0.5+svn20090706-2ubuntu2, Copyright (c) 2000-2009 Fabrice Bellard, et al.
  configuration: --extra-version=4:0.5+svn20090706-2ubuntu2 --prefix=/usr --enable-avfilter --enable-avfilter-lavf --enable-vdpau --enable-bzlib --enable-libgsm --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-pthreads --enable-zlib --disable-stripping --disable-vhook --enable-gpl --enable-postproc --enable-swscale --enable-x11grab --enable-libdc1394 --extra-cflags=-I/build/buildd/ffmpeg-0.5+svn20090706/debian/include --enable-shared --disable-static
  libavutil     49.15. 0 / 49.15. 0
  libavcodec    52.20. 0 / 52.20. 0
  libavformat   52.31. 0 / 52.31. 0
  libavdevice   52. 1. 0 / 52. 1. 0
  libavfilter    0. 4. 0 /  0. 4. 0
  libswscale     0. 7. 1 /  0. 7. 1
  libpostproc   51. 2. 0 / 51. 2. 0
  built on Oct 13 2009 22:15:16, gcc: 4.4.1
[video4linux @ 0x85222c0]VIDIOCSWIN: Bad address
/dev/video0: I/O error occurred
Usually that means that input file is truncated and/or corrupted.


더불정보기술 X-LUK DBC-UP
$ ffmpeg -y -f video4linux -r 30 -s 320x240 -i /dev/video1 http://localhost:8090/feed1.ffm
FFmpeg version SVN-r19352-4:0.5+svn20090706-2ubuntu2, Copyright (c) 2000-2009 Fabrice Bellard, et al.
  configuration: --extra-version=4:0.5+svn20090706-2ubuntu2 --prefix=/usr --enable-avfilter --enable-avfilter-lavf --enable-vdpau --enable-bzlib --enable-libgsm --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-pthreads --enable-zlib --disable-stripping --disable-vhook --enable-gpl --enable-postproc --enable-swscale --enable-x11grab --enable-libdc1394 --extra-cflags=-I/build/buildd/ffmpeg-0.5+svn20090706/debian/include --enable-shared --disable-static
  libavutil     49.15. 0 / 49.15. 0
  libavcodec    52.20. 0 / 52.20. 0
  libavformat   52.31. 0 / 52.31. 0
  libavdevice   52. 1. 0 / 52. 1. 0
  libavfilter    0. 4. 0 /  0. 4. 0
  libswscale     0. 7. 1 /  0. 7. 1
  libpostproc   51. 2. 0 / 51. 2. 0
  built on Oct 13 2009 22:15:16, gcc: 4.4.1
Input #0, video4linux, from '/dev/video1':
  Duration: N/A, start: 1260102822.110153, bitrate: 27647 kb/s
    Stream #0.0: Video: rawvideo, yuv420p, 320x240, 27647 kb/s, 30 tbr, 1000k tbn, 30 tbc
Output #0, ffm, to 'http://localhost:8090/feed1.ffm':
    Stream #0.0: Video: mpeg1video, yuv420p, 320x240, q=3-31, 512 kb/s, 1000k tbn, 30 tbc
Stream mapping:
  Stream #0.0 -> #0.0
Press [q] to stop encoding
[mpeg1video @ 0x9940160]rc buffer underflow
VIDIOCMCAPTURE: Invalid argument
frame=    1 fps=  0 q=31.7 Lsize=      12kB time=10000000000.00 bitrate=   0.0kbits/s
video:8kB audio:0kB global headers:0kB muxing overhead 54.352468%



2010.02.18 추가

열화와 같은 성원(?)으로 드라이버 및 프로그램을 올려 놓습니다.
X-LUK DBC-UP 에는 xp용 드라이버와 감시프로그램이
vista 에는 vista용 드라이버가 들어있습니다.


'Linux API > v4l' 카테고리의 다른 글

v4l2 debug  (0) 2022.07.13
v4l2-ctl 밝기 조절  (0) 2022.07.06
v4l2 timestamp  (0) 2017.04.19
uv4l  (0) 2015.09.13
Posted by 구차니