Use tcflush() in patty_kiss_tnc_new()
Use tcflush() to initialize TTY state in patty_kiss_tnc_new(), so that no unexpected data causes KISS framing errors
This commit is contained in:
		
							parent
							
								
									08509999c4
								
							
						
					
					
						commit
						b99a6607ba
					
				
					 1 changed files with 5 additions and 0 deletions
				
			
		| 
						 | 
					@ -143,6 +143,10 @@ patty_kiss_tnc *patty_kiss_tnc_new_fd(int fd) {
 | 
				
			||||||
        if (tcsetattr(fd, TCSANOW, &tnc->attrs) < 0) {
 | 
					        if (tcsetattr(fd, TCSANOW, &tnc->attrs) < 0) {
 | 
				
			||||||
            goto error_tcsetattr;
 | 
					            goto error_tcsetattr;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (tcflush(fd, TCIOFLUSH) < 0) {
 | 
				
			||||||
 | 
					            goto error_tcflush;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    tnc->fd      =  fd;
 | 
					    tnc->fd      =  fd;
 | 
				
			||||||
| 
						 | 
					@ -154,6 +158,7 @@ patty_kiss_tnc *patty_kiss_tnc_new_fd(int fd) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return tnc;
 | 
					    return tnc;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					error_tcflush:
 | 
				
			||||||
error_tcsetattr:
 | 
					error_tcsetattr:
 | 
				
			||||||
error_tcgetattr:
 | 
					error_tcgetattr:
 | 
				
			||||||
error_malloc_buf:
 | 
					error_malloc_buf:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue