বুধবার, ১৭ এপ্রিল, ২০১৩

Problem Read 111 Byte From Serial Port - C And C++ | Dream.In.Code


Example
#{example}
"); ipb.editor_values.get('templates')['togglesource'] = new Template("
??? Cancel Source Edit
"); ipb.editor_values.get('templates')['toolbar'] = new Template(""); ipb.editor_values.get('templates')['button'] = new Template("
  • Icon
  • "); ipb.editor_values.get('templates')['menu_item'] = new Template("
  • #{title}
  • "); ipb.editor_values.get('templates')['togglesource'] = new Template("
    ??? Cancel Source Edit
    "); ipb.editor_values.get('templates')['emoticons_showall'] = new Template(""); ipb.editor_values.get('templates')['emoticon_wrapper'] = new Template("

    Emoticons

    "); // Add smilies into the mix ipb.editor_values.set( 'show_emoticon_link', false ); ipb.editor_values.set( 'bbcodes', $H({"snapback":{"id":"1","title":"Post Snap Back","desc":"This tag displays a little linked image which links back to a post - used when quoting posts from the board. Opens in same window by default.","tag":"snapback","useoption":"0","example":"[snapback]100[/snapback]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"0","image":""},"topic":{"id":"5","title":"Topic Link","desc":"This tag provides an easy way to link to a topic","tag":"topic","useoption":"1","example":"[topic=1]Click me![/topic]","switch_option":"0","menu_option_text":"Enter the topic ID","menu_content_text":"Enter the title for this link","single_tag":"0","optional_option":"0","image":""},"post":{"id":"6","title":"Post Link","desc":"This tag provides an easy way to link to a post.","tag":"post","useoption":"1","example":"[post=1]Click me![/post]","switch_option":"0","menu_option_text":"Enter the Post ID","menu_content_text":"Enter the title for this link","single_tag":"0","optional_option":"0","image":""},"spoiler":{"id":"7","title":"Spoiler","desc":"Spoiler tag","tag":"spoiler","useoption":"0","example":"[spoiler]Some hidden text[/spoiler]","switch_option":"0","menu_option_text":"","menu_content_text":"Enter the text to be masked","single_tag":"0","optional_option":"0","image":""},"acronym":{"id":"8","title":"Acronym","desc":"Allows you to make an acronym that will display a description when moused over","tag":"acronym","useoption":"1","example":"[acronym='Laugh Out Loud']lol[/acronym]","switch_option":"0","menu_option_text":"Enter the description for this acronym (EG: Laugh Out Loud)","menu_content_text":"Enter the acronym (EG: lol)","single_tag":"0","optional_option":"0","image":""},"hr":{"id":"12","title":"Horizontal Rule","desc":"Adds a horizontal rule to separate text","tag":"hr","useoption":"0","example":"[hr]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"1","optional_option":"0","image":""},"php":{"id":"14","title":"PHP Code","desc":"Allows you to enter PHP code into a formatted/highlighted syntax box","tag":"php","useoption":"0","example":"[php]$variable = true;\n\nprint_r($variable);[/php]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"0","image":""},"html":{"id":"15","title":"HTML Code","desc":"Allows you to enter formatted/syntax-highlighted HTML code","tag":"html","useoption":"0","example":"[html]\n \n[/html]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"0","image":""},"sql":{"id":"16","title":"SQL Code","desc":"Allows you to enter formatted/syntax-highlighted SQL code","tag":"sql","useoption":"0","example":"[sql]SELECT p.*, t.* FROM posts p LEFT JOIN topics t ON t.tid=p.topic_id WHERE t.tid=7[/sql]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"0","image":""},"xml":{"id":"17","title":"XML Code","desc":"Allows you to enter formatted/syntax-highlighted XML code","tag":"xml","useoption":"0","example":"[xml]\n \n Test\n \n[/xml]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"0","image":""},"member":{"id":"31","title":"Member","desc":"Given a member name, a link is automatically generated to the member's profile","tag":"member","useoption":"1","example":"[member=skyhawk133] runs this site.","switch_option":"0","menu_option_text":"Input Username of Member","menu_content_text":"","single_tag":"1","optional_option":"0","image":"memberbbcode.png"},"extract":{"id":"33","title":"Extract Blog Entry","desc":"This will allow users to define an extract for an entry. Only this piece of the entry will be displayed on the main blog page and will show up in the RSS feed.","tag":"extract","useoption":"0","example":"[extract]This is an example![/extract]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"0","image":""},"blog":{"id":"34","title":"Blog Link","desc":"This tag provides an easy way to link to a blog.","tag":"blog","useoption":"1","example":"[blog=100]Click me![/blog]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"0","image":""},"entry":{"id":"35","title":"Blog Entry Link","desc":"This tag provides an easy way to link to a blog entry.","tag":"entry","useoption":"1","example":"[entry=100]Click me![/entry]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"0","image":""},"twitter":{"id":"36","title":"Twitter","desc":"A tag to link to a user's twitter account","tag":"twitter","useoption":"0","example":"[twitter]userName[/twitter]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"0","image":"twitter.png"},"inline":{"id":"37","title":"Inline Code","desc":"Formats code inline instead of in a seperate code box. ","tag":"inline","useoption":"0","example":"[inline]style=\"font-size: 12px;\"[/inline]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"0","image":""},"il":{"id":"38","title":"Abbreviated Inline (IL)","desc":"Abbreviated version of the [inline] tag. ","tag":"il","useoption":"0","example":"[il]Code Here[/il]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"0","image":"il2.png"},"code":{"id":"41","title":"Code","desc":"Allows you to enter general code","tag":"code","useoption":"1","example":"[code]$text = 'Some long code here';[/code]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"1","image":""}}) ); ipb.vars['emoticon_url'] = "http://cdn.dreamincode.net/forums/public/style_emoticons/default"; //Search Setup ipb.vars['search_type'] = 'forum'; ipb.vars['search_type_id'] = 15; ipb.vars['search_type_2'] = 'topic'; ipb.vars['search_type_id_2'] = 318645; //]]>

    2 Replies - 36 Views - Last Post: Today, 07:31 AM Rate Topic: -----

    #1 Marvin_G ?Icon User is offline

    Reputation: 0

    • Posts: 1
    • Joined: Yesterday, 11:07 PM

    Posted Yesterday, 11:17 PM

    Hello guys, i'm new here. i have a code which will write command to serial port and after that read the output from the port. I've tested to read 8 byte data and it works but when i tried to read 111 byte of data, it's not working. Below is my code, please do take a look. Takes in advance.
    
   #include <stdio.h>   /* Standard input/output definitions */  #include <string.h>  /* String function definitions */  #include <unistd.h>  /* UNIX standard function definitions */  #include <fcntl.h>   /* File control definitions */  #include <errno.h>   /* Error number definitions */  #include <termios.h> /* POSIX terminal control definitions */   /*   * 'open_port()' - Open serial port 1.   *   * Returns the file descriptor on success or -1 on error.   */   int open_port(void)  {    int fd;                                   /* File descriptor for the port */     fd = open("/dev/ttyUSB0", O_RDWR | O_NOCTTY | O_NDELAY);     if (fd < 0) {                                              /* Could not open the port */      fprintf(stderr, "open_port: Unable to open /dev/ttyUSB0 - %s\n",              strerror(errno));    }     return (fd);  }  void main() {  int mainfd=0, i;                                            /* File descriptor */  char cnt, result2;  unsigned char result,chout;  struct termios options;  FILE *fp;      mainfd = open_port();   fcntl(mainfd, F_SETFL, FNDELAY);                  /* Configure port reading */                                      /* Get the current options for the port */  tcgetattr(mainfd, &options);  cfsetispeed(&options, B19200);                 /* Set the baud rates to 19200 */  cfsetospeed(&options, B19200);                                         /* Enable the receiver and set local mode */  options.c_cflag |= (CLOCAL | CREAD);  options.c_cflag &= ~PARENB; /* Mask the character size to 8 bits, no parity */  options.c_cflag &= ~CSTOPB;  options.c_cflag &= ~CSIZE;  options.c_cflag |=  CS8;                              /* Select 8 data bits */  options.c_cflag &= ~CRTSCTS;               /* Disable hardware flow control */                                      /* Enable data to be processed as raw input */  options.c_lflag &= ~(ICANON | ECHO | ISIG);                                                 /* Set the new options for the port */  tcsetattr(mainfd, TCSANOW, &options);   result2 = tcsetattr(mainfd, TCSANOW, &options);  if ( result2 == -1 ) { perror("error: tcsetattr"); }  if ( result2 != 0 ) { fprintf(stderr,"error in tcsetattr, result = %d\n", result2); }   result2 = write(mainfd,"\xF5\x23\x00\x00\x00\x00\x23\xF5",8);  if ( result2 == -1 ) { perror("error: write"); }  if ( result2 != 8 ) { fprintf(stderr,"error in write, result = %d\n", result2); }     usleep(5000000);      /* wait for 5 second*/   fp = fopen("results_eigenvalue", "w");   /*open and write into existing file*/   for(i=0;i<111;i++) {  result = read(mainfd, &chout, sizeof(chout));          /* Read character from ABU (Auto buffering Unit) */  if ( result == -1 ) { perror("error: read"); }  /*if ( result!= 1 ) { fprintf(stderr,"error in read, result = %d\n", result); }      if (chout!= 0)*/     fprintf(fp,"%02x ",chout);   }                                                /* Close the serial port */   close(mainfd);  }  


    Is This A Good Question/Topic? 0

    Replies To: Problem Read 111 byte from serial port

    #2 macosxnerd101 ?Icon User is online

    Reputation: 8924

    • Posts: 33,067
    • Joined: 27-December 08

    Re: Problem Read 111 byte from serial port

    Posted Today, 07:18 AM

    Moved to C/C++. Please do not post help questions in the Challenges subforum. The Challenges forums are for fun challenges, not help/homework questions.


    #3 jimblumberg ?Icon User is online

    Reputation: 2940

    • Posts: 8,929
    • Joined: 25-December 09

    Re: Problem Read 111 byte from serial port

    Posted Today, 07:31 AM


    Page 1 of 1


    Source: http://www.dreamincode.net/forums/topic/318645-problem-read-111-byte-from-serial-port/

    chris carter superbowl 2012 kickoff time what time is the super bowl 2012 nfl mvp lana del rey snl performance nick diaz sheryl sandberg

    কোন মন্তব্য নেই:

    একটি মন্তব্য পোস্ট করুন