Index: src/Stk500.C =================================================================== RCS file: /cvsroot/uisp/uisp/src/Stk500.C,v retrieving revision 1.1 diff -u -p -r1.1 Stk500.C --- src/Stk500.C 25 May 2002 17:59:46 -0000 1.1 +++ src/Stk500.C 29 May 2002 19:25:27 -0000 @@ -157,13 +157,26 @@ const TStk500::SPrgPart TStk500::prg_par }; + /* Read byte from active segment at address addr. */ TByte TStk500::ReadByte(TAddr addr){ + TByte val; + + if (segment == SEG_FUSE) + { + throw Error_Device ("TStk500::ReadByte not implemented for Fuse segment yet."); + } + else + { + /* FIXME: TRoth/2002-05-29: This is still broken. If flash or eeprom + changes after the calling ReadMem(), you won't ever see the change. */ - if (read_buffer == NULL) - ReadMem(); + if (read_buffer[segment] == NULL) + ReadMem(); - return read_buffer[addr]; + val = read_buffer[segment][addr]; + } + return val; } @@ -311,16 +324,18 @@ void TStk500::ReadMem(){ TAddr addr; TByte seg; - read_buffer = new TByte[GetSegmentSize()]; - if (segment == SEG_FLASH) { wordsize = 2; seg = Flash; - } else { + } else if (segment == SEG_EEPROM) { wordsize = 1; seg = EEPROM; + } else { + throw Error_Device ("TStk500::ReadMem() called for invalid segment."); } + read_buffer[segment] = new TByte[GetSegmentSize()]; + EnterProgrammingMode(); addr = 0; @@ -336,7 +351,7 @@ void TStk500::ReadMem(){ buf[3] = seg; Send(buf, sizeof(ReadMemory), 2+0x100); - memcpy(read_buffer+addr, buf+1, 0x100); + memcpy(read_buffer[segment]+addr, buf+1, 0x100); } LeaveProgrammingMode(); @@ -371,7 +386,8 @@ TStk500::TStk500() { Identify(); write_buffer = NULL; - read_buffer = NULL; + read_buffer[SEG_FLASH] = NULL; + read_buffer[SEG_EEPROM] = NULL; maxaddr = 0; } @@ -379,5 +395,6 @@ TStk500::TStk500() { TStk500::~TStk500() { delete write_buffer; - delete read_buffer; + delete read_buffer[SEG_FLASH]; + delete read_buffer[SEG_EEPROM]; } Index: src/Stk500.h =================================================================== RCS file: /cvsroot/uisp/uisp/src/Stk500.h,v retrieving revision 1.1 diff -u -p -r1.1 Stk500.h --- src/Stk500.h 25 May 2002 17:59:46 -0000 1.1 +++ src/Stk500.h 29 May 2002 19:25:27 -0000 @@ -41,7 +41,7 @@ private: int desired_part; TByte* write_buffer; - TByte* read_buffer; + TByte* read_buffer[2]; /* buffer for SEG_FLASH and SEG_EEPROM */ TAddr maxaddr; static const TByte pSTK500[];