프로그램 종료후 쉘이 이상?

달그림자의 이미지

현재 임베디드 리눅스 위에 프로그램을 하나 돌리고 있습니다.
간단히, 시리얼로 특정 코드를 받으면 그 코드를 실행시켜 주는 프로그램입니다.
(임베디드 리눅스 window 컴퓨터 )
프로그램 -------시리얼 통신 ------- hyper 터미널

문제가, 프로그램 종료후

[/root@...]$

이 상태에서, 글자를 치면 화면에 나타나지 않습니다. 나타나지는 않지만 입력은 받고 있습니다.

또한, 엔터를 치면 다음 라인으로 넘어가는게 아니라, 옆으로 뜨네요.

[/root@...]$[/root@...]$ <- 이렇게요.

어디서 잘못됐는지, 알수가 없네요.

ALT + D 를 눌러 로그아웃해서 다시 로그인 하면 정상적인 상태로 돌아옵니다.

도움 부탁드리네요^^/~

p.s 시리얼 통신 여는 부분 혹시나 해서 올립니다.

int __open_serial(char *sport, int baud, char stop)
{
	 int fd;
 	 struct termios tm;

  	  // Return Serial Communication File Descriptor 
	  if ((fd = open(sport, O_RDWR | O_NOCTTY)) == -1)
	 	 ErrorMessage("Can't Open Serial FD");

	  memset(&tm, 0, sizeof(tm));

	  // Serial Setting 
	  SET(tm.c_cflag, CLOCAL | CREAD);
	  cfsetospeed(&tm, baud);
	  cfsetispeed(&tm, baud);
	  REMOVE(tm.c_cflag, PARENB);
	  REMOVE(tm.c_cflag, CSIZE);
	  SET(tm.c_cflag, CS8);
	  if (stop) {
		    SET(tm.c_cflag, CSTOPB);
	  } else {
		    REMOVE(tm.c_cflag, CSTOPB);
	  }

	  REMOVE(tm.c_lflag, ICANON | ECHO | ECHOE | ISIG);
	  SET(tm.c_iflag, IGNPAR | IGNBRK | INPCK);
	  REMOVE(tm.c_oflag, OPOST);

	  tm.c_cc[VEOF]		= 4;
	  tm.c_cc[VMIN]		= 1;

	  tcsetattr(fd, TCSANOW, &tm);
	
	  return (fd);
}
pynoos의 이미지

REMOVE(tm.c_lflag, ICANON | ECHO | ECHOE | ISIG);

이부분이 그런일을 하는 것 같군요.

일반적으로 ssh 등으로 다른 host 접속할 때, ctrl+C 를 눌러 종료시키면, handler 등에서 terminal 의 echo 상태를 원상복구시켜 줘야하는데 그렇지 못한 경우에 발생합니다.

debugging 하실 때 도움이 될 만한 명령어는

stty echo

이지요.

달그림자의 이미지

terminal IO쪽을 잘 알지 못해서...^^

프로그램에서 시리얼 셋팅하기전에
기존 터미널 설정 값을 저장해 두고,(tcgetattr)
종료하기전에 복구 하는 방식으로 해서(tcsetattr)
잘 해결 됐네요...^^

답변 감사 드립니다(__)~

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.