=== src/AvrDummy.C ================================================================== --- src/AvrDummy.C (revision 8) +++ src/AvrDummy.C (revision 20) @@ -622,7 +622,7 @@ /* Device Command line options ... */ if (GetCmdParam("-dno-poll", false)){use_data_polling=false;} - EnableAvr(); + if (!GetCmdParam("-dno-enable", false)) EnableAvr(); } #endif === src/DAPA.h ================================================================== --- src/DAPA.h (revision 8) +++ src/DAPA.h (revision 20) @@ -69,7 +69,6 @@ private: int SendRecv(int); /* low level access to parallel port lines */ - void OutReset(int); void OutSck(int); void OutData(int); void SckDelay(); @@ -89,6 +88,7 @@ /* If enable command 0x53 did not echo back, give a positive SCK pulse and retry again. */ + void OutReset(int); void PulseSck(); void PulseReset(); void Init(); === src/Main.C ================================================================== --- src/Main.C (revision 8) +++ src/Main.C (revision 20) @@ -36,6 +36,8 @@ #include #include #include +#include +#include #include "Terminal.h" #include "MotIntl.h" #include "AvrAtmel.h" @@ -56,6 +58,8 @@ TMotIntl motintl; TTerminal terminal; +volatile int quit=0; + const char* version = "uisp version %s\n" "(C) 1997-1999 Uros Platise, 2000-2003 Marek Michalkiewicz\n" "\nuisp is free software, covered by the GNU General Public License.\n" @@ -230,6 +234,12 @@ } +void SigHandler(int sig) +{ + quit=1; +} + + int main(int _argc, const char* _argv[]){ int return_val=0; argc = _argc; @@ -288,7 +298,79 @@ #ifndef NO_DAPA else if (val) { /* The TDAPA() constructor will drop setuid privileges after - opening the lpt ioport. */ + opening the lpt ioport. */ + if (GetCmdParam("--console", false)) + { + unsigned char buffer[16]; + fd_set set; + struct timeval tv; + int l,i; + TDAPA *ad=new TDAPA; + struct termios tios, tios2; + int hex_out; + + + signal(SIGQUIT, SigHandler); + signal(SIGINT, SigHandler); + signal(SIGTERM, SigHandler); + signal(SIGPIPE, SigHandler); + + hex_out=!!GetCmdParam("--hex-out", false); + + printf("Connection established.\n"); + if (tcgetattr(0, &tios) == -1) + throw Error_Device("Cannot get terminal attributes"); + memcpy(&tios2, &tios, sizeof(tios)); + tios2.c_cc[VMIN]=0; + tios2.c_lflag &= ~(ICANON | ECHO); + if (tcsetattr(0, TCSANOW, &tios2) == -1) + throw Error_Device("Cannot get terminal attributes"); + ad->OutReset(1); + + while(!quit) + { + FD_ZERO(&set); + FD_SET(0,&set); + tv.tv_sec=0; + tv.tv_usec=100000; + if (select(1,&set, NULL,NULL, &tv)) + { + l=read(0, buffer+1, sizeof(buffer)-1); + if (l <= 0) break; + } + else + l=0; + + buffer[0]=0x7f; + ad->Send(buffer, l+1, sizeof(buffer)); + for(i=0; i=0; l--) putchar((buffer[i] & (1 << l)) ? '1' : '0'); + putchar('\n'); + } + else + putchar(buffer[i]); + } + } + + fflush(stdout); + } + + if (tcsetattr(0, TCSANOW, &tios) == -1) + throw Error_Device("Cannot get terminal attributes"); + return 0; + } + device = new TAvrDummy(); } #endif @@ -296,7 +378,7 @@ /* Check Device's bad command line params. */ for (int i=1; iReadByte(AVR_FUSE_HIGH_ADDR)); printf("Fuse Extended Byte = 0x%02x\n", device->ReadByte(AVR_FUSE_EXT_ADDR)); printf("Calibration Byte = 0x%02x -- Read Only\n", - device->ReadByte(AVR_CAL_ADDR)); + device->ReadByte(AVR_CAL_ADDR)); bits = device->ReadByte(AVR_LOCK_ADDR); printf("Lock Bits = 0x%02x\n", bits); @@ -359,11 +441,11 @@ if (sscanf(val, "%x", &bits) == 1) { - device->WriteByte( AVR_FUSE_LOW_ADDR, (TByte)bits ); - printf("\nFuse Low Byte set to 0x%02x\n", (TByte)bits); + device->WriteByte( AVR_FUSE_LOW_ADDR, (TByte)bits ); + printf("\nFuse Low Byte set to 0x%02x\n", (TByte)bits); } else - throw Error_Device("Invalid argument for --wr_fuse_l."); + throw Error_Device("Invalid argument for --wr_fuse_l."); device->SetSegment(old_seg); } @@ -376,11 +458,11 @@ if (sscanf(val, "%x", &bits) == 1) { - device->WriteByte( AVR_FUSE_HIGH_ADDR, (TByte)bits ); - printf("\nFuse High Byte set to 0x%02x\n", (TByte)bits); + device->WriteByte( AVR_FUSE_HIGH_ADDR, (TByte)bits ); + printf("\nFuse High Byte set to 0x%02x\n", (TByte)bits); } else - throw Error_Device("Invalid argument for --wr_fuse_h."); + throw Error_Device("Invalid argument for --wr_fuse_h."); device->SetSegment(old_seg); } @@ -393,11 +475,11 @@ if (sscanf(val, "%x", &bits) == 1) { - device->WriteByte( AVR_FUSE_EXT_ADDR, (TByte)bits ); - printf("\nFuse Extended Byte set to 0x%02x\n", (TByte)bits); + device->WriteByte( AVR_FUSE_EXT_ADDR, (TByte)bits ); + printf("\nFuse Extended Byte set to 0x%02x\n", (TByte)bits); } else - throw Error_Device("Invalid argument for --wr_fuse_e."); + throw Error_Device("Invalid argument for --wr_fuse_e."); device->SetSegment(old_seg); } @@ -408,11 +490,11 @@ if (sscanf(val, "%x", &bits) == 1) { - device->WriteLockBits( (TByte)bits ); - printf("\nLock Bits set to 0x%02x\n", (TByte)bits); + device->WriteLockBits( (TByte)bits ); + printf("\nLock Bits set to 0x%02x\n", (TByte)bits); } else - throw Error_Device("Invalid argument for --wr_lock."); + throw Error_Device("Invalid argument for --wr_lock."); } if (GetCmdParam("--lock", false)) @@ -422,10 +504,10 @@ printf("\nLock Bits set to 0x%02x\n", 0xfc); } - /* enter terminal */ - + /* enter terminal */ + if (GetCmdParam("--terminal", false)){terminal.Run();} - + /* Check bad command line parameters */ for (int i=1; i