Man, this stuff is kinda hard when the standards are ill-specified
This commit is contained in:
		
							parent
							
								
									fac432cdb4
								
							
						
					
					
						commit
						17dd963f97
					
				
					 1 changed files with 16 additions and 6 deletions
				
			
		
							
								
								
									
										22
									
								
								src/kiss.c
									
										
									
									
									
								
							
							
						
						
									
										22
									
								
								src/kiss.c
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -6,13 +6,13 @@ enum kiss_flags {
 | 
			
		|||
    KISS_ESCAPE = 0x02
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
int patty_kiss_read(int fd, void *buf, size_t *len, int *channel) {
 | 
			
		||||
ssize_t patty_kiss_read(int fd, void *buf, size_t len, int *port) {
 | 
			
		||||
    int flags = KISS_NONE;
 | 
			
		||||
    size_t i, b = 0;
 | 
			
		||||
 | 
			
		||||
    *channel = 0;
 | 
			
		||||
    *port = 0;
 | 
			
		||||
 | 
			
		||||
    for (i=0; i<PATTY_KISS_BUFLEN; i++) {
 | 
			
		||||
    for (i=0; i<len; i++) {
 | 
			
		||||
        unsigned char c = ((char *)buf)[i];
 | 
			
		||||
 | 
			
		||||
        if (flags & KISS_FRAME == 0) {
 | 
			
		||||
| 
						 | 
				
			
			@ -48,13 +48,23 @@ int patty_kiss_read(int fd, void *buf, size_t *len, int *channel) {
 | 
			
		|||
                break;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            /*
 | 
			
		||||
             * Not all KISS TNCs will emit a type byte at the start of a frame
 | 
			
		||||
             * to the host; if the low nybble has a value of zero, then presume
 | 
			
		||||
             * the high nybble to be the radio port number from which the
 | 
			
		||||
             * packet originated.
 | 
			
		||||
             */
 | 
			
		||||
            if (c & 0x0f == 0) {
 | 
			
		||||
                *port = (c & 0xf0) >> 4;
 | 
			
		||||
 | 
			
		||||
                continue;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            ((char *)buf)[b++] = c;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    *len = b + 1;
 | 
			
		||||
 | 
			
		||||
    return 0;
 | 
			
		||||
    return b + 1;
 | 
			
		||||
 | 
			
		||||
error_io:
 | 
			
		||||
    return -1;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue