728x90

원문 링크 : http://www.armadeus.com/wiki/index.php?title=Serial_ports_usage_on_Linux


http://unix.stackexchange.com/questions/117037/how-to-send-data-to-a-serial-port-and-see-any-answer


Changing port parameters


To get current parameters

# stty -F /dev/ttyUSB0

speed 115200 baud;

intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = ^J;

eol2 = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W;

lnext = ^V; flush = ^O; min = 1; time = 0;

-brkint ixoff -imaxbel

-iexten -echoctl


To only get actual speed:

# stty -F /dev/ttySMX0 speed

115200


By default serial ports are configured as terminal emulator. If you want to use them as "raw" serial port you will have to do first (example for port 1):

# stty -F /dev/ttyUSB1 raw

# stty -F /dev/ttyUSB1 -echo -echoe -echok


To change baudrate of port 2 to 115200 :

# stty -F /dev/ttyUSB2 115200

stty -speed 19200 < /dev/ttyS1
stty -speed 19200 -f /dev/ttyS1


Sending/Receiving data

Send

# echo "HELLO" > /dev/ttyUSB0

echo -e "\x7E\x03\xD0\xAF und normaler Text" > /dev/ttyS0

The echo -e command enables the interpretation of backslash escapes.


To receive data (ASCII in that case):

# cat /dev/ttyUSB0



728x90

'Programming > linux왕초보' 카테고리의 다른 글

use vim like as source insight  (0) 2016.04.06
[ubuntu] change default shell  (0) 2016.03.22
GDB를 사용한 CORE 파일의 분석  (0) 2016.02.05
kernel make menuconfig error  (0) 2016.01.21
Caching your GitHub password in Git  (0) 2016.01.08
process 종료  (0) 2015.05.28
fork  (0) 2015.05.26
Linux SSD 최적화  (0) 2015.04.17
fflush, fileno  (0) 2015.04.07
[Linux] stream write  (0) 2015.03.26
728x90

eixt()


#include <stdlib.h>
void exit (int status);

C library 종료 단계
1. atexit(), on_exit() 등록함수를 역순으로 출력
2. std I/O stream flush
3. tmpfile()로 만든 임시 파일 삭제
4. _exit() 호출

#include <unistd.h>
void _exit (int status);

사용하지 않는 자원 정리
allocated memory, opend file,, system V semaphore 등
kernel은 process를 제거한 다음 parent에게 통보함

application은 _exit()를 직접 호출할 수는 있지만 의미없다. vfork() 사용자는 fork 이후 exit()대신 _exit()호출해야 함.


atexit()

#include <stdlib.h>
int atexit (void (*function) (void));

주의 : parameter, return이 없다.
POSIX에서는 ATEXIT_MAX까지 함수 등록을 지원해야 하며 최소 32가 되어야 한다.
sysconf()와 _SC_ATEXIT_MAX로 정확한 값을 알 수 있다.

long atexit_max;
atexit_max = sysconf(_SC_ATEXIT_MAX);
printf("atexit_max = %ld\n", atexit_max);




on_exit()

#include <stdlib.h>
int on_exit (void (*function)(int, void *), void *arg);

parameter를 허용함
주의 : 솔라리스에서는 더이상 이 함수를 지원하지 않는다.

void my_function(int status, void *arg);


SIGCHLD
child process가 죽으면 kernel이 parent에게 통보함
signal(), sigaction()을 이용하여 처리.

728x90

'Programming > linux왕초보' 카테고리의 다른 글

[ubuntu] change default shell  (0) 2016.03.22
GDB를 사용한 CORE 파일의 분석  (0) 2016.02.05
kernel make menuconfig error  (0) 2016.01.21
Caching your GitHub password in Git  (0) 2016.01.08
Serial ports usage on Linux  (0) 2016.01.08
fork  (0) 2015.05.26
Linux SSD 최적화  (0) 2015.04.17
fflush, fileno  (0) 2015.04.07
[Linux] stream write  (0) 2015.03.26
linux filesystem 사용 용량 확인  (0) 2015.03.18
728x90

fork()

#include <sys/types.h>
#include <unistd.h>

pid_t fork(void);

* child pid는 parent pid와 다르게 새롭게 생성
* 0이 pid로 반환되면 child
* 대기중인 signal은 정리되며, child에게 상속되지 않음
* fd lock은 상속되지 않음




background로 다른 프로그램 실행시킬 때 많이 사용한다.




728x90

'Programming > linux왕초보' 카테고리의 다른 글

GDB를 사용한 CORE 파일의 분석  (0) 2016.02.05
kernel make menuconfig error  (0) 2016.01.21
Caching your GitHub password in Git  (0) 2016.01.08
Serial ports usage on Linux  (0) 2016.01.08
process 종료  (0) 2015.05.28
Linux SSD 최적화  (0) 2015.04.17
fflush, fileno  (0) 2015.04.07
[Linux] stream write  (0) 2015.03.26
linux filesystem 사용 용량 확인  (0) 2015.03.18
[Linux] Select and Poll  (0) 2015.01.27
728x90

http://www.smallake.kr/?p=7709


위의 링크 원문에서 일부 발췌

원문제목은 "Linux환경에서 SSD 성능 최적화하기"


이처럼 SSD는 미리 블럭을 비워놓지 않으면, 쓰기작업을 할때 블럭을 비우는 작업을 해야하기 때문에 쓰기 성능이 떨어집니다. 이런 단점을 해결하기 위하여 운영체제가 한가할 때 삭제한다고 표시한 데이터를 미리 비워 두도록 하는 기능을 만들었고 이를 TRIM이라고 합니다. TRIM은 읽기와 무관하고 오직 쓰기와 관계합니다. 또한 SSD가 TRIM을 지원하여야 하고 OS도 지원하여야 합니다. Linux의 경우 TRIM을 활성화하려면 다음과 같이 명령어를 실행합니다.

이제 TRIM을 OS와 SSD가 지원한다고 하면 File System을 Mount를 할 때 옵션을 추가해주어야 합니다.

그러면 현재 사용중인 Linux의 Scheduler가 무엇이고 어떻게 변경하는지 알아보겠습니다.

변경은 아래와 같이 합니다.



====================================================================

hdparm으로 확인했는데 SSD가 trim을 지원하지 않는다면?

$ sudo fstrim / -v

와 같이 수동으로 할 수 있다. 그런데 막상 해보니까 한번에 0 bytes wre trimmed가 나오지 않아 몇번 반복해줘야 했다.

728x90

'Programming > linux왕초보' 카테고리의 다른 글

kernel make menuconfig error  (0) 2016.01.21
Caching your GitHub password in Git  (0) 2016.01.08
Serial ports usage on Linux  (0) 2016.01.08
process 종료  (0) 2015.05.28
fork  (0) 2015.05.26
fflush, fileno  (0) 2015.04.07
[Linux] stream write  (0) 2015.03.26
linux filesystem 사용 용량 확인  (0) 2015.03.18
[Linux] Select and Poll  (0) 2015.01.27
Example syntax for Secure Copy (scp) : scp사용법  (0) 2014.04.02

+ Recent posts