Add basic termios to the rpi platform to allow echoing/newline translation to be controlled.
--HG-- branch : dtrg-videocore rename : plat/rpi/include/unistd.h => plat/rpi/include/termios.h rename : plat/rpi/libsys/write.c => plat/rpi/libsys/tcgetattr.c rename : plat/rpi/libsys/write.c => plat/rpi/libsys/tcsetattr.c
This commit is contained in:
		
							parent
							
								
									074b42aa97
								
							
						
					
					
						commit
						2054618e75
					
				
					 7 changed files with 83 additions and 14 deletions
				
			
		|  | @ -13,6 +13,7 @@ D := plat/rpi/ | |||
| 
 | ||||
| platform-headers := \
 | ||||
| 	unistd.h \
 | ||||
| 	termios.h \
 | ||||
| 	pi.h \
 | ||||
| 	ack/config.h | ||||
| 
 | ||||
|  | @ -33,7 +34,9 @@ platform-libsys := \ | |||
| 	kill.c \
 | ||||
| 	lseek.c \
 | ||||
| 	time.c \
 | ||||
| 	signal.c | ||||
| 	signal.c \
 | ||||
| 	tcgetattr.c \
 | ||||
| 	tcsetattr.c | ||||
| 
 | ||||
| $(eval $(call build-platform)) | ||||
| 
 | ||||
|  |  | |||
							
								
								
									
										31
									
								
								plat/rpi/include/termios.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								plat/rpi/include/termios.h
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,31 @@ | |||
| /*
 | ||||
|  * Raspberry Pi support library for the ACK | ||||
|  * © 2013 David Given | ||||
|  * This file is redistributable under the terms of the 3-clause BSD license. | ||||
|  * See the file 'Copying' in the root of the distribution for the full text. | ||||
|  */ | ||||
| 
 | ||||
| #ifndef _TERMIOS_H | ||||
| #define _TERMIOS_H | ||||
| 
 | ||||
| typedef unsigned char tcflag_t; | ||||
| 
 | ||||
| struct termios | ||||
| { | ||||
|     tcflag_t c_iflag; | ||||
|     tcflag_t c_oflag; | ||||
|     tcflag_t c_lflag; | ||||
| }; | ||||
| 
 | ||||
| #define ONLCR 1 | ||||
| #define ECHO 2 | ||||
| #define INLCR 4 | ||||
| 
 | ||||
| #define TCSANOW 0 | ||||
| #define TCSADRAIN 1 | ||||
| #define TCSAFLUSH 2 | ||||
| 
 | ||||
| extern int tcgetattr(int fd, struct termios* t); | ||||
| extern int tcsetattr(int fd, int actions, struct termios* t); | ||||
| 
 | ||||
| #endif | ||||
|  | @ -13,6 +13,6 @@ extern unsigned char _sys_rawread(void); | |||
| 
 | ||||
| extern void _sys_write_tty(char c); | ||||
| 
 | ||||
| /* extern int _sys_ttyflags; */ | ||||
| extern int _sys_ttyflags; | ||||
| 
 | ||||
| #endif | ||||
|  |  | |||
|  | @ -8,6 +8,7 @@ | |||
| #include <stdlib.h> | ||||
| #include <errno.h> | ||||
| #include <unistd.h> | ||||
| #include <termios.h> | ||||
| #include "libsys.h" | ||||
| 
 | ||||
| int read(int fd, void* buffer, size_t count) | ||||
|  | @ -30,15 +31,10 @@ int read(int fd, void* buffer, size_t count) | |||
| 	/* Read one byte. */ | ||||
| 	 | ||||
| 	i = _sys_rawread(); | ||||
| #if 0 | ||||
| 	if ((i == '\r') && !(_sys_ttyflags & RAW))  | ||||
| 	if ((i == '\r') && !(_sys_ttyflags & INLCR)) | ||||
| 		i = '\n'; | ||||
| 	if (_sys_ttyflags & ECHO) | ||||
| 		_sys_write_tty(i); | ||||
| #endif | ||||
| 	if (i == '\r')  | ||||
| 		i = '\n'; | ||||
| 	_sys_write_tty(i); | ||||
| 
 | ||||
| 	*(char*)buffer = i; | ||||
| 	return 1; | ||||
|  |  | |||
							
								
								
									
										21
									
								
								plat/rpi/libsys/tcgetattr.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								plat/rpi/libsys/tcgetattr.c
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,21 @@ | |||
| /*
 | ||||
|  * Raspberry Pi support library for the ACK | ||||
|  * © 2013 David Given | ||||
|  * This file is redistributable under the terms of the 3-clause BSD license. | ||||
|  * See the file 'Copying' in the root of the distribution for the full text. | ||||
|  */ | ||||
| 
 | ||||
| #include <stdlib.h> | ||||
| #include <errno.h> | ||||
| #include <unistd.h> | ||||
| #include <termios.h> | ||||
| #include "libsys.h" | ||||
| 
 | ||||
| int tcgetattr(int fd, struct termios* t) | ||||
| { | ||||
|     t->c_iflag = _sys_ttyflags & INLCR; | ||||
|     t->c_oflag = _sys_ttyflags & ONLCR; | ||||
|     t->c_lflag = _sys_ttyflags & ECHO; | ||||
|     return 0; | ||||
| } | ||||
| 
 | ||||
							
								
								
									
										19
									
								
								plat/rpi/libsys/tcsetattr.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								plat/rpi/libsys/tcsetattr.c
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,19 @@ | |||
| /*
 | ||||
|  * Raspberry Pi support library for the ACK | ||||
|  * © 2013 David Given | ||||
|  * This file is redistributable under the terms of the 3-clause BSD license. | ||||
|  * See the file 'Copying' in the root of the distribution for the full text. | ||||
|  */ | ||||
| 
 | ||||
| #include <stdlib.h> | ||||
| #include <errno.h> | ||||
| #include <unistd.h> | ||||
| #include <termios.h> | ||||
| #include "libsys.h" | ||||
| 
 | ||||
| int tcsetattr(int fd, int actions, struct termios* t) | ||||
| { | ||||
| 	_sys_ttyflags = t->c_iflag | t->c_oflag | t->c_lflag; | ||||
|     return 0; | ||||
| } | ||||
| 
 | ||||
|  | @ -8,16 +8,15 @@ | |||
| #include <stdlib.h> | ||||
| #include <errno.h> | ||||
| #include <unistd.h> | ||||
| #include <termios.h> | ||||
| #include "libsys.h" | ||||
| 
 | ||||
| int _sys_ttyflags = ONLCR | INLCR | ECHO; | ||||
| 
 | ||||
| void _sys_write_tty(char c) | ||||
| { | ||||
| 	_sys_rawwrite(c); | ||||
| #if 0 | ||||
| 	if ((c == '\n') && !(_sys_ttyflags & RAW)) | ||||
| 		_sys_rawwrite('\r'); | ||||
| #endif | ||||
| 	if (c == '\n') | ||||
| 	if ((c == '\n') && (_sys_ttyflags & ONLCR)) | ||||
| 		_sys_rawwrite('\r'); | ||||
| } | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue