임베디드 485통신 개발 중 슬레이브에서 온 데이터가 읽히지 않습니다.

yanggungg의 이미지

485를 이용해 마스터와 슬레이브간 통신을 구현하고 있습니다.

현재까지 마스터에서 보낸 신호를 슬레이브가 받아 응답을 출력하는 부분까지는 구현된 상태입니다.
(이 부분은 PC와도 라인을 같이 연결해서 시리얼캡쳐 프로그램을 이용해 확인하였습니다.)
(슬레이브의 응답데이터도 기술문서에 작성되어있는 응답데이터와 일치하는것 또한 확인하였습니다.)

문제는 마스터 쪽에서 슬레이브의 응답데이터가 읽히지 않는다는 것입니다.

구현에 문제가 있나싶어 다른 종류의 슬레이브 장치를 구해 마스터로 신호를 보내봤는데 이 때는 잘 읽힙니다.

뭔가 놓친 부분이 있긴 한것 같은데 제가 485통신에 대해 배우거나 작업을 한적이 없어서 전혀 감을 잡을 수 없어 글 올립니다.

아래는 마스터의 시리얼을 read 모드로 셋팅할 때 호출하는 터미널셋팅입니다.

static int _set_read_termios()
{
    struct termios tio;
    int modemctlline;
 
    tio.c_cflag = B9600 | CRTSCTS | CS8 | CLOCAL | CREAD;
    tio.c_iflag = 0;
    tio.c_oflag = 0;
    tio.c_lflag = 0;
    tio.c_cc[VINTR]    = 0;     /* Ctrl-c */
    tio.c_cc[VQUIT]    = 0;     /* Ctrl-\ */
    tio.c_cc[VERASE]   = 0;     /* del */
    tio.c_cc[VKILL]    = 0;     /* @ */
    tio.c_cc[VEOF]     = 4;     /* Ctrl-d */
    tio.c_cc[VTIME]    = 0;     /* inter-character timer unused */
    tio.c_cc[VMIN]     = 0;     /* blocking read until 1 character arrives */
    tio.c_cc[VSWTC]    = 0;     /* '\0' */
    tio.c_cc[VSTART]   = 0;     /* Ctrl-q */
    tio.c_cc[VSTOP]    = 0;     /* Ctrl-s */
    tio.c_cc[VSUSP]    = 0;     /* Ctrl-z */
    tio.c_cc[VEOL]     = 0;     /* '\0' */
    tio.c_cc[VREPRINT] = 0;     /* Ctrl-r */
    tio.c_cc[VDISCARD] = 0;     /* Ctrl-u */
    tio.c_cc[VWERASE]  = 0;     /* Ctrl-w */
    tio.c_cc[VLNEXT]   = 0;     /* Ctrl-v */
    tio.c_cc[VEOL2]    = 0;     /* '\0' */
 
    modemctlline = TIOCM_RTS;
    ioctl( ircm.fd, TIOCMBIC, &modemctlline );
 
    tcflush(ircm.fd, TCIFLUSH);
    tcsetattr(ircm.fd, TCSANOW, &tio);
    g_usleep(10*1000);
 
    return 0;
}

댓글 달기

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