리눅스에서 시리얼로 센서값 받기

콩수니의 이미지

우분트 컴터로요
온동/습도/co2 센서기에서 시리얼로 rs-232로 통하여서 usb로 해서
pc로 들어오는 센서값을 c언어로 찍어보려하는데요
minicom을 통해서 센서값이 들어오는것은 확인했는데
c언어로 하니깐 값이 안들어와요

씨리얼도 잘 열어서 안열리면 종료하도록 해서 잘 연결이 된듯한데 값을
받지 못하는지 모르겠습니다.
혹시 단순하게 집고 넘어간것이 있는지?ㅠㅠ

그냥 간단히 힌트만 던져주세요

poplinux의 이미지

시리얼 속도는 설정하셨는지요?

========================
조직 : E.L.D(Embedded Linux Developer/Designer)
블로그 : poplinux@tistory.com
카페 : cafe.naver.com/poplinux

임베디드 리눅스 관련 프리렌서 지향

콩수니의 이미지

네 했습니다!ㅜ

devband

익명 사용자의 이미지

http://code.google.com/p/picocom/
로 컴파일해서 접속해 보시고
작성하신 소스 코드와 어떻게 다른지 비교해 보세요.

콩수니의 이미지

제가 시리얼 통신쪽은 무뇌아라 ㅠㅠ
소스를 다음과 같이 했는데 무엇이...ㅠ
#include
#include
#include
#include
#include
#include
#include

#define TOUCHPORT "/dev/ttyUSB0"
#define BAUDRATE B9600
#define BUFSIZE 18
#define TRUE 1
#define FALSE 0
#define U32 unsigned int

#define Debug
#define SerialSet
void SerialRead();

int main(void)
{
#ifdef Debug
printf("main --> Start !!\n");
printf("SerialRead Call !!\n");
#endif

SerialRead();
return 0;
}

void SerialRead()
{
char buf[BUFSIZE]={0};
int fd=0,r=0;
int i=0;
#ifdef Debug
printf("SerialRead ---> Start!!\n");
printf("TouchPort !!\n");
#endif
printf("포트를 열기\n");
fd = open(TOUCHPORT,O_RDWR | O_NOCTTY);

if(fd<0) {
perror(TOUCHPORT);
exit(-1);
}
printf("포트를 열기 성공!\n");

#ifdef SerialSet
#ifdef Debug
printf("SerialSet .. Start !!\n");
#endif

struct termios tio;
tcgetattr(fd,&tio);
tio.c_cflag = CS8 | CLOCAL | CREAD;
tio.c_cflag = IGNPAR | ICRNL;
tio.c_cflag = 0;
tio.c_cc[VTIME]=0;
tio.c_cc[VMIN] =0;
tcflush(fd,TCIFLUSH);
tcsetattr(fd,TCSANOW,&tio);

#ifdef Debug
printf("SerialSet .. End!!\n");
#endif
#endif

#ifdef Debug
printf("TouchPort descript ==> %d\n",r);
#endif

while(1) {

r = read(fd,buf,sizeof(buf));

if(r <=0)
{
printf("reply\n");
continue;
}

for(i=0;i printf("%x",buf[i]);
}
memset(buf,0,sizeof(buf));
}//while
}//end

devband

댓글 달기

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
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.