765 lines
24 KiB
Plaintext
765 lines
24 KiB
Plaintext
|
|
|
|
#if 0
|
|
int PASCAL WinMain(HINSTANCE /*hInstance*/,HINSTANCE /*hPrevInstance*/,LPSTR /*lpszCmdLine*/,int /*nCmdShow*/)
|
|
{
|
|
CommControl commControl;
|
|
DeviceControlBlock deviceControlBlock;
|
|
CommStatus commStatus;
|
|
BYTE charByte;
|
|
String strString;
|
|
BYTE ioBuffer[256];
|
|
DWORD eventMask;
|
|
|
|
commControl.open(CommControl::PortCOM1);
|
|
if(!commControl.isOkay())return FALSE;
|
|
commControl.getDeviceControlBlock(deviceControlBlock);
|
|
deviceControlBlock.parity(DeviceControlBlock::ParityNone);
|
|
deviceControlBlock.baudRate(1200);
|
|
deviceControlBlock.dataBits(8);
|
|
deviceControlBlock.stopBits(0);
|
|
if(!commControl.setDeviceControlBlock(deviceControlBlock))::OutputDebugString("Set operation failed\n");
|
|
|
|
::OutputDebugString("waiting for break signal...\n");
|
|
commControl.setEventMask(CommControl::EventBreak);
|
|
commControl.waitEvent();
|
|
::OutputDebugString("break received, loading code...\n");
|
|
|
|
for(int index=0;index<256;index++)ioBuffer[index]=index;
|
|
charByte=0xFF;
|
|
commControl.write(&charByte,sizeof(charByte));
|
|
commControl.write(ioBuffer,sizeof(ioBuffer));
|
|
::memset(ioBuffer,0,sizeof(ioBuffer));
|
|
|
|
::OutputDebugString("receiving echo\n");
|
|
while(TRUE)
|
|
{
|
|
commControl.clearError(commStatus);
|
|
if(commStatus.bytesInReceiveQueue())
|
|
{
|
|
commControl.read(ioBuffer,sizeof(ioBuffer));
|
|
for(index=0;index+8<sizeof(ioBuffer);index+=8)
|
|
{
|
|
::sprintf(strString,"%02x %02x %02x %02x %02x %02x %02x %02x\n",
|
|
ioBuffer[index],ioBuffer[index+1],ioBuffer[index+2],ioBuffer[index+3],ioBuffer[index+4],
|
|
ioBuffer[index+5],ioBuffer[index+6],ioBuffer[index+7]);
|
|
::OutputDebugString(strString);
|
|
}
|
|
break;
|
|
}
|
|
::Sleep(1000);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
#if 0
|
|
deviceControlBlock.binaryEnabled(TRUE);
|
|
deviceControlBlock.enableParity(TRUE);
|
|
deviceControlBlock.baudRate(1200);
|
|
deviceControlBlock.parity(DeviceControlBlock::ParityNone);
|
|
deviceControlBlock.dataBits(8);
|
|
deviceControlBlock.stopBits(1);
|
|
if(!commControl.setDeviceControlBlock(deviceControlBlock))
|
|
{
|
|
::GetLastError();
|
|
::OutputDebugString("Set operation failed\n");
|
|
}
|
|
|
|
|
|
commControl.setEventMask(CommControl::EventAll);
|
|
::OutputDebugString("waiting for event\n");
|
|
// commControl.setBreak();
|
|
commControl.waitEvent(eventMask);
|
|
if(eventMask&CommControl::EventBreak)::OutputDebugString("break occurred\n");
|
|
else ::OutputDebugString("some other event occurred\n");
|
|
#endif
|
|
|
|
#if 0
|
|
commControl.getDeviceControlBlock(deviceControlBlock);
|
|
|
|
deviceControlBlock.baudRate(1200);
|
|
deviceControlBlock.parity(DeviceControlBlock::ParityNone);
|
|
// deviceControlBlock.dataBits(8);
|
|
// deviceControlBlock.stopBits(1);
|
|
if(!commControl.setDeviceControlBlock(deviceControlBlock))::OutputDebugString("Set operation failed\n");
|
|
commControl.getDeviceControlBlock(deviceControlBlock);
|
|
|
|
|
|
for(int index=0;index<256;index++)ioBuffer[index]=index;
|
|
charByte=0xFF;
|
|
commControl.write(&charByte,sizeof(charByte));
|
|
commControl.write(ioBuffer,sizeof(ioBuffer));
|
|
::memset(ioBuffer,0,sizeof(ioBuffer));
|
|
commControl.read(ioBuffer,sizeof(ioBuffer));
|
|
for(index=0;index+8<sizeof(ioBuffer);index+=8)
|
|
{
|
|
::sprintf(strString,"%02x %02x %02x %02x %02x %02x %02x %02x\n",
|
|
ioBuffer[index],ioBuffer[index+1],ioBuffer[index+2],ioBuffer[index+3],ioBuffer[index+4],
|
|
ioBuffer[index+5],ioBuffer[index+6],ioBuffer[index+7]);
|
|
::OutputDebugString(strString);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// commControl.writeLine("ATE1");
|
|
// commControl.readLine(strString);
|
|
/// commControl.writeLine("ATDT 5551212;");
|
|
// commControl.readLine(strString);
|
|
|
|
|
|
// while(TRUE)
|
|
// {
|
|
// ::OutputDebugString("sending 0xFF");
|
|
// inByte=0xFF;
|
|
// commControl.write(&inByte,sizeof(inByte));
|
|
// ::OutputDebugString("attempting read...\n");
|
|
// commControl.clearError(commStatus);
|
|
// if(commStatus.bytesInReceiveQueue())
|
|
// {
|
|
// String strString;
|
|
// for(int index=0;index<commStatus.bytesInReceiveQueue();index++)
|
|
// {
|
|
// commControl.read(&inByte,sizeof(inByte));
|
|
// ::sprintf(strString,"%x %d\n",inByte);
|
|
// ::OutputDebugString(strString);
|
|
// ::MessageBeep(0);
|
|
// }
|
|
// }
|
|
// else ::OutputDebugString("No data in receive queue.\n");
|
|
// ::OutputDebugString("sleeping\n");
|
|
// ::Sleep(1500);
|
|
// }
|
|
commControl.close();
|
|
return FALSE;
|
|
|
|
// MainWindow mainWindow;
|
|
// return mainWindow.messageLoop();
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
#if 0
|
|
#include <common/windows.hpp>
|
|
#include <common/openfile.hpp>
|
|
#include <common/block.hpp>
|
|
#include <thread/mthread.hpp>
|
|
#include <sbb/dcb.hpp>
|
|
#include <sbb/commstat.hpp>
|
|
#include <sbb/commctrl.hpp>
|
|
#include <sbb/thmsgx.hpp>
|
|
|
|
void main(int argc,char **argv)
|
|
{
|
|
CommControl commControl;
|
|
CommStatus commStatus;
|
|
DeviceControlBlock deviceControlBlock;
|
|
DeviceControlBlock sanityBlock;
|
|
BYTE ioBuffer[256];
|
|
|
|
commControl.open(CommControl::PortCOM1);
|
|
if(!commControl.isOkay())return;
|
|
commControl.getDeviceControlBlock(deviceControlBlock);
|
|
deviceControlBlock.parity(DeviceControlBlock::ParityNone);
|
|
// deviceControlBlock.dataBits(8);
|
|
// deviceControlBlock.stopBits(1);
|
|
// deviceControlBlock.baudRate(1200);
|
|
if(!commControl.setDeviceControlBlock(deviceControlBlock))
|
|
{
|
|
String strCode;
|
|
DWORD errorCode(::GetLastError());
|
|
::sprintf(strCode,"0x%08lx %d\n",errorCode,errorCode);
|
|
::OutputDebugString(strCode);
|
|
}
|
|
String strRcv;
|
|
commControl.writeLine("ATE1");
|
|
commControl.readLine(strRcv);
|
|
::OutputDebugString(strRcv);
|
|
commControl.writeLine("ATDT 9,1,5162620924");
|
|
// commControl.readLine(strRcv);
|
|
::OutputDebugString(strRcv);
|
|
commControl.clearError(commStatus);
|
|
if(commStatus.bytesInReceiveQueue())
|
|
{
|
|
commControl.readLine(strRcv);
|
|
::OutputDebugString(strRcv);
|
|
}
|
|
commControl.close();
|
|
}
|
|
#endif
|
|
|
|
#include <fileio/fileio.hpp>
|
|
|
|
String strPathFileName("c:\\work\\as68hc11\\code2.asm");
|
|
String strLine;
|
|
FileIO outFile;
|
|
|
|
outFile.open(strPathFileName); //,FileIO::GenericRead,FileIO::FileShareRead);
|
|
if(!outFile.isOkay())return FALSE;
|
|
while(outFile.readLine(strLine));
|
|
outFile.close();
|
|
outFile.open(strPathFileName,FileIO::GenericRead,FileIO::FileShareRead);
|
|
if(!outFile.isOkay())return FALSE;
|
|
while(outFile.readLine(strLine));
|
|
return FALSE;
|
|
|
|
|
|
|
|
void MainFrame::createToolBar(void)
|
|
{
|
|
Block<AddBitmap> addBitmaps;
|
|
|
|
mToolBar.create(*this,ToolBarID);
|
|
addBitmaps.insert(&AddBitmap(0,HINST_COMMCTRL));
|
|
if(!mToolBar.addBitmaps(addBitmaps))return;
|
|
mToolBar.addButton(ToolBarButton(STD_FILENEW,MenuFileNew,ToolBarButton::StateEnabled,ToolBarButton::StyleButton));
|
|
mToolBar.addButton(ToolBarButton(STD_FILEOPEN,MenuFileOpen,ToolBarButton::StateEnabled,ToolBarButton::StyleButton));
|
|
mToolBar.addButton(ToolBarButton(STD_FILESAVE,MenuFileSave,ToolBarButton::StateEnabled,ToolBarButton::StyleButton));
|
|
mToolBar.addButton(ToolBarButton(STD_CUT,112,ToolBarButton::StateEnabled,ToolBarButton::StyleButton));
|
|
mToolBar.addButton(ToolBarButton(STD_COPY,110,ToolBarButton::StateEnabled,ToolBarButton::StyleButton));
|
|
mToolBar.addButton(ToolBarButton(STD_PASTE,111,ToolBarButton::StateEnabled,ToolBarButton::StyleButton));
|
|
// mToolBar.addButton(ToolBarButton(STD_PRINT,RiskMenuPrint,ToolBarButton::StateEnabled,ToolBarButton::StyleButton));
|
|
// mToolBar.addButton(ToolBarButton(STD_PRINTPRE,RiskMenuPageSetup,ToolBarButton::StateEnabled,ToolBarButton::StyleButton));
|
|
mToolBar.addButton(ToolBarButton(STD_FIND,122,ToolBarButton::StateEnabled,ToolBarButton::StyleButton));
|
|
mToolBar.show(SW_SHOW);
|
|
// mToolBar.addButton(ToolBarButton(STD_HELP,RiskMenuHelpContents,ToolBarButton::StateEnabled,ToolBarButton::StyleButton));
|
|
|
|
// mToolBar.addButton(ToolBarButton(STD_DELETE,114,ToolBarButton::StateEnabled,ToolBarButton::StyleButton));
|
|
// mToolBar.addButton(ToolBarButton(STD_PROPERTIES,117,ToolBarButton::StateEnabled,ToolBarButton::StyleButton));
|
|
// mToolBar.addButton(ToolBarButton(STD_REDOW,119,ToolBarButton::StateEnabled,ToolBarButton::StyleButton));
|
|
// mToolBar.addButton(ToolBarButton(STD_REPLACE,121,ToolBarButton::StateEnabled,ToolBarButton::StyleButton));
|
|
// mToolBar.addButton(ToolBarButton(STD_UNDO,123,ToolBarButton::StateEnabled,ToolBarButton::StyleButton));
|
|
}
|
|
|
|
|
|
|
|
|
|
// mToolBar.show(SW_SHOW);
|
|
// mToolBar.addButton(ToolBarButton(STD_PRINT,RiskMenuPrint,ToolBarButton::StateEnabled,ToolBarButton::StyleButton));
|
|
// mToolBar.addButton(ToolBarButton(STD_PRINTPRE,RiskMenuPageSetup,ToolBarButton::StateEnabled,ToolBarButton::StyleButton));
|
|
// mToolBar.addButton(ToolBarButton(STD_HELP,RiskMenuHelpContents,ToolBarButton::StateEnabled,ToolBarButton::StyleButton));
|
|
// mToolBar.addButton(ToolBarButton(STD_DELETE,114,ToolBarButton::StateEnabled,ToolBarButton::StyleButton));
|
|
// mToolBar.addButton(ToolBarButton(STD_PROPERTIES,117,ToolBarButton::StateEnabled,ToolBarButton::StyleButton));
|
|
// mToolBar.addButton(ToolBarButton(STD_REDOW,119,ToolBarButton::StateEnabled,ToolBarButton::StyleButton));
|
|
// mToolBar.addButton(ToolBarButton(STD_REPLACE,121,ToolBarButton::StateEnabled,ToolBarButton::StyleButton));
|
|
// mToolBar.addButton(ToolBarButton(STD_UNDO,123,ToolBarButton::StateEnabled,ToolBarButton::StyleButton));
|
|
|
|
|
|
|
|
|
|
|
|
// commControl.read(&address,sizeof(address));
|
|
// ::sprintf(strString,"%lx",int(address));
|
|
// ::sprintf(strString,"%d%d%d%d%d%d%d%d",
|
|
// int((address&128?1:0)),int((address&64?1:0)),int((address&32?1:0)),int((address&16?1:0)),
|
|
// int((address&8?1:0)),int((address&4?1:0)),int((address&2?1:0)),int((address&1?1:0)));
|
|
// ::MessageBox(::GetFocus(),(LPSTR)strString,"VALUE",MB_OK);
|
|
// commControl.write(&charByte,sizeof(charByte));
|
|
|
|
|
|
// WORD address;
|
|
|
|
|
|
// typedef void (PASCAL * DEBUGPROC)(CommControl &commControl);
|
|
// Library procLib("procLib.dll");
|
|
// if(!procLib.isOkay())return FALSE;
|
|
// if(!procLib.procIn("_procDebug@4"))return FALSE;
|
|
// ((DEBUGPROC)procLib.procAddress("_procDebug@4"))(commControl);
|
|
|
|
|
|
//c ((COMPROC)procLib.procAddress("_procDebug@4"))(commControl);
|
|
|
|
/// ::memset(rcvBuffer,0,sizeof(rcvBuffer));
|
|
|
|
// WORD address;
|
|
// String strString;
|
|
// WORD count(0);
|
|
// while(TRUE)
|
|
// {
|
|
// commControl.read(&address,sizeof(address));
|
|
// ::sprintf(strString,"%d) %08lx\n",++count,int(address));
|
|
// ::OutputDebugString(strString);
|
|
// commControl.write(&charByte,sizeof(charByte));
|
|
// }
|
|
|
|
// commControl.read(rcvBuffer,1);
|
|
// commControl.read(rcvBuffer+1,
|
|
|
|
// commControl.read(rcvBuffer+2,1);
|
|
// commControl.read(rcvBuffer+3,1);
|
|
|
|
// commControl.setEventMask(CommControl::EventBreak);
|
|
// if(!commControl.waitEvent()){mStatusBar->setText("timeout waiting for break.");return FALSE;}
|
|
// else mStatusBar->setText("received break");
|
|
// commControl.write(&charByte,sizeof(charByte));
|
|
// ::memset(rcvBuffer,0,sizeof(rcvBuffer));
|
|
// charByte=0;
|
|
// commControl.read(&charByte,1);
|
|
// commControl.read(&charByte,1);
|
|
|
|
// ldd SWIHANDLER ; get address of SWIHANDLER to register D
|
|
// bsr WRITEWORD ; send it out to SCI
|
|
// bsr WAITCHAR ; wait for a character
|
|
// ldd [SWI] ; load contents of SWI vector ?
|
|
// bsr WRITEWORD ; send it out to SCI
|
|
// bsr WAITCHAR ; wait for a character
|
|
// ldd SWIHANDLER ; load address of SWIHANDLER to register D
|
|
// std [SWI] ; store SWIHANDLER at swi vector ?
|
|
// ldd [SWI] ; load contents of SWIHANDLER
|
|
// bsr WRITEWORD ; send it out to SCI
|
|
// bsr WAITCHAR ; wait for a character
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
; *********************************************************************************
|
|
;
|
|
; ldd REGS ; load REGS into D
|
|
; std [MEMLOC] ; store D into MEMLOC
|
|
;CONTINUE equ * ; sync address
|
|
; ldd [MEMLOC] ; load D with value at MEMLOC
|
|
; xgdx ; exchange D with X
|
|
; ldab ix,00h ; load B with byte at address of X plus 00h
|
|
; bsr WRITECHAR ; write the contents of B to SCI
|
|
; ldd [MEMLOC] ; reload the value at MEMLOC
|
|
; addd 0001h ; increment value
|
|
; cpd CONFIG ; compare register D with CONFIG
|
|
; bgt END ; if D is greater than CONFIG we're all done
|
|
; std [MEMLOC] ; store value back into MEMLOC
|
|
; jmp CONTINUE ; keep going
|
|
;END equ *
|
|
; std [EEPROM]
|
|
; ldd [EEPROM]
|
|
; bsr WRITEWORD
|
|
; bsr WAITCHAR
|
|
|
|
|
|
|
|
|
|
|
|
; ldab EVENTCHAR
|
|
; bsr WRITECHAR
|
|
; ldab [PPROG]
|
|
; bsr WRITECHAR
|
|
; bsr WAITCHAR
|
|
|
|
|
|
; ldab EVENTCHAR
|
|
; bsr WRITECHAR
|
|
; ldab [BPROT]
|
|
; bsr WRITECHAR
|
|
; bsr WAITCHAR
|
|
|
|
; ldab 00h
|
|
; stab [BPROT]
|
|
|
|
; ldab EVENTCHAR
|
|
; bsr WRITECHAR
|
|
; ldab [BPROT]
|
|
; bsr WRITECHAR
|
|
; bsr WAITCHAR
|
|
|
|
; ldab 11h
|
|
; stab [EEPROM]
|
|
; ldab EVENTCHAR
|
|
; bsr WRITECHAR
|
|
; ldab [EEPROM]
|
|
; bsr WRITECHAR
|
|
; bsr WAITCHAR
|
|
|
|
; ldab EVENTEND
|
|
; bsr WRITECHAR
|
|
|
|
; ldab EVENTWORD
|
|
; bsr WRITECHAR
|
|
; ldd 5555h
|
|
; std [EEPROM]
|
|
; ldd [EEPROM]
|
|
; bsr WRITEWORD
|
|
; bsr READCHAR
|
|
; ldab EVENTEND
|
|
; bsr WRITECHAR
|
|
; ldd [msg] ; this seems to generate a compile error
|
|
; bsr WRITEENDEVENT ; write end event character to the SCI
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define STRING_REGISTERPORTA 700
|
|
#define STRING_REGISTERCONFIG 763
|
|
|
|
|
|
|
|
mOwnerDrawList->insertString("PORTA");
|
|
mOwnerDrawList->insertString("RESERVED");
|
|
mOwnerDrawList->insertString("PIOC");
|
|
mOwnerDrawList->insertString("PORTC");
|
|
mOwnerDrawList->insertString("PORTB");
|
|
mOwnerDrawList->insertString("PORTCL");
|
|
mOwnerDrawList->insertString("RESERVED");
|
|
mOwnerDrawList->insertString("DDRC");
|
|
mOwnerDrawList->insertString("PORTD");
|
|
mOwnerDrawList->insertString("DDRD");
|
|
mOwnerDrawList->insertString("PORTE");
|
|
mOwnerDrawList->insertString("CFORC");
|
|
mOwnerDrawList->insertString("OC1M");
|
|
mOwnerDrawList->insertString("OC1D");
|
|
mOwnerDrawList->insertString("TCNT(Hi)");
|
|
mOwnerDrawList->insertString("TCNT(Lo)");
|
|
mOwnerDrawList->insertString("TIC1(Hi)");
|
|
mOwnerDrawList->insertString("TIC1(Lo)");
|
|
mOwnerDrawList->insertString("TIC2(Hi)");
|
|
mOwnerDrawList->insertString("TIC2(Lo)");
|
|
mOwnerDrawList->insertString("TIC3(Hi)");
|
|
mOwnerDrawList->insertString("TIC3(Lo)");
|
|
mOwnerDrawList->insertString("TOC1(Hi)");
|
|
mOwnerDrawList->insertString("TOC1(Lo)");
|
|
mOwnerDrawList->insertString("TOC2(Hi)");
|
|
mOwnerDrawList->insertString("TOC2(Lo)");
|
|
mOwnerDrawList->insertString("TOC3(Hi)");
|
|
mOwnerDrawList->insertString("TOC3(Lo)");
|
|
mOwnerDrawList->insertString("TOC4(Hi)");
|
|
mOwnerDrawList->insertString("TOC4(Lo)");
|
|
mOwnerDrawList->insertString("TI405(Hi)");
|
|
mOwnerDrawList->insertString("TI405(Lo)");
|
|
mOwnerDrawList->insertString("TCTL1");
|
|
mOwnerDrawList->insertString("TCTL2");
|
|
mOwnerDrawList->insertString("TMSK1");
|
|
mOwnerDrawList->insertString("TFLG1");
|
|
mOwnerDrawList->insertString("TMSK2");
|
|
mOwnerDrawList->insertString("TFLG2");
|
|
mOwnerDrawList->insertString("PACTL");
|
|
mOwnerDrawList->insertString("PACNT");
|
|
mOwnerDrawList->insertString("SPCR");
|
|
mOwnerDrawList->insertString("SPSR");
|
|
mOwnerDrawList->insertString("SPDR");
|
|
mOwnerDrawList->insertString("BAUD");
|
|
mOwnerDrawList->insertString("SCCR1");
|
|
mOwnerDrawList->insertString("SCCR2");
|
|
mOwnerDrawList->insertString("SCSR");
|
|
mOwnerDrawList->insertString("SCDR");
|
|
mOwnerDrawList->insertString("ADCTL");
|
|
mOwnerDrawList->insertString("ADR1");
|
|
mOwnerDrawList->insertString("ADR2");
|
|
mOwnerDrawList->insertString("ADR3");
|
|
mOwnerDrawList->insertString("ADR4");
|
|
mOwnerDrawList->insertString("BPROT");
|
|
mOwnerDrawList->insertString("EPROG");
|
|
mOwnerDrawList->insertString("RESERVED");
|
|
mOwnerDrawList->insertString("RESERVED");
|
|
mOwnerDrawList->insertString("OPTION");
|
|
mOwnerDrawList->insertString("COPRST");
|
|
mOwnerDrawList->insertString("PPROG");
|
|
mOwnerDrawList->insertString("HPRIO");
|
|
mOwnerDrawList->insertString("INIT");
|
|
mOwnerDrawList->insertString("TEST1");
|
|
mOwnerDrawList->insertString("CONFIG");
|
|
|
|
|
|
|
|
#if 0
|
|
#include <common/library.hpp>
|
|
|
|
BOOL MainFrame::codeLoad(const String &strPathBinary)
|
|
{
|
|
FileHandle inFile;
|
|
BYTE sndBuffer[256];
|
|
BYTE rcvBuffer[256];
|
|
BYTE *ptrByte;
|
|
BYTE charByte(0xFF);
|
|
WORD codeLength(0);
|
|
DeviceControlBlock deviceControlBlock;
|
|
CommControl commControl;
|
|
CommStatus commStatus;
|
|
|
|
if(!inFile.open(strPathBinary)){mStatusBar->setText("Error opening file.");return FALSE;}
|
|
if(!commControl.open(CommControl::Port(0))){mStatusBar->setText("Error opening port.");return FALSE;}
|
|
commControl.getDeviceControlBlock(deviceControlBlock);
|
|
deviceControlBlock.baudRate(1200);
|
|
deviceControlBlock.parity(DeviceControlBlock::Parity(0));
|
|
deviceControlBlock.dataBits(8);
|
|
deviceControlBlock.stopBits(0);
|
|
if(!commControl.setDeviceControlBlock(deviceControlBlock))mStatusBar->setText("Failed to apply settings.");
|
|
mStatusBar->setText("waiting for break signal....");
|
|
commControl.setEventMask(CommControl::EventBreak);
|
|
if(!commControl.waitEvent()){mStatusBar->setText("timeout waiting for break.");return FALSE;}
|
|
mStatusBar->setText("break received, loading code...");
|
|
::memset(sndBuffer,1,sizeof(sndBuffer));
|
|
::memset(rcvBuffer,0,sizeof(rcvBuffer));
|
|
ptrByte=sndBuffer;
|
|
while(inFile.read(*ptrByte)){codeLength++;ptrByte++;}
|
|
commControl.write(&charByte,sizeof(charByte));
|
|
commControl.read(&charByte,sizeof(charByte));
|
|
commControl.write(sndBuffer,sizeof(sndBuffer));
|
|
if(!commControl.read(rcvBuffer,sizeof(sndBuffer))){mStatusBar->setText("Failed to verify write.");return FALSE;}
|
|
if(!::memcmp(rcvBuffer,sndBuffer,codeLength))mStatusBar->setText("Code has been loaded onto device.");
|
|
else {mStatusBar->setText("Failed to verify write.");return FALSE;}
|
|
|
|
|
|
// event types
|
|
// 0x00 - character
|
|
// 0x01 - WORD
|
|
// 0x02 - DWORD
|
|
// 0x03 - varchar : [WORD:count,countcharacters]
|
|
// 0xFF - end
|
|
|
|
|
|
BYTE event; // 0x00=char, 0x01=WORD, 0x02=varchar
|
|
BYTE ack(0x00);
|
|
char charData;
|
|
WORD wordData;
|
|
DWORD dwordData;
|
|
int index;
|
|
BOOL reading(TRUE);
|
|
String strString;
|
|
int map(0x1000);
|
|
|
|
enum Event{EventSingleByte=0x00,EventDoubleByte=0x01,EventQuadByte=0x02,EventVarByte=0x03,
|
|
EventRegs=0x04,EventEnd=0xFF};
|
|
while(reading)
|
|
{
|
|
commControl.read(&event,sizeof(event));
|
|
switch(Event(event))
|
|
{
|
|
case EventSingleByte :
|
|
commControl.read(&charData,sizeof(charData));
|
|
commControl.write(&ack,sizeof(ack));
|
|
::sprintf(strString,"(%d%d%d%d%d%d%d%d) %lx\n",
|
|
int((charData&128?1:0)),int((charData&64?1:0)),int((charData&32?1:0)),int((charData&16?1:0)),
|
|
int((charData&8?1:0)),int((charData&4?1:0)),int((charData&2?1:0)),int((charData&1?1:0)),
|
|
int(charData));
|
|
::OutputDebugString(strString);
|
|
::MessageBox(::GetFocus(),(LPSTR)strString,"M68HC11",MB_OK);
|
|
break;
|
|
case EventDoubleByte :
|
|
commControl.read(&wordData,sizeof(wordData));
|
|
commControl.write(&ack,sizeof(ack));
|
|
::sprintf(strString,"%lx\n",int(wordData));
|
|
::OutputDebugString(strString);
|
|
::MessageBox(::GetFocus(),(LPSTR)strString,"M68HC11",MB_OK);
|
|
break;
|
|
case EventQuadByte :
|
|
commControl.read(&dwordData,sizeof(dwordData));
|
|
commControl.write(&ack,sizeof(ack));
|
|
::sprintf(strString,"%lx\n",int(dwordData));
|
|
::OutputDebugString(strString);
|
|
::MessageBox(::GetFocus(),(LPSTR)strString,"M68HC11",MB_OK);
|
|
break;
|
|
case EventVarByte :
|
|
commControl.read(&wordData,sizeof(wordData));
|
|
for(index=0;index<wordData;index++)
|
|
{
|
|
commControl.read(&charData,sizeof(charData));
|
|
::sprintf(strString,"(%d%d%d%d%d%d%d%d) %lx\n",
|
|
int((charData&128?1:0)),int((charData&64?1:0)),int((charData&32?1:0)),int((charData&16?1:0)),
|
|
int((charData&8?1:0)),int((charData&4?1:0)),int((charData&2?1:0)),int((charData&1?1:0)),
|
|
int(charData));
|
|
::OutputDebugString(strString);
|
|
}
|
|
commControl.write(&ack,sizeof(ack));
|
|
break;
|
|
case EventRegs :
|
|
::OutputDebugString("EventRegs\n");
|
|
map=0x1000;
|
|
for(index=0;index<64;index++)
|
|
{
|
|
commControl.read(&charData,sizeof(charData));
|
|
::sprintf(strString,"[%08lx] (%d%d%d%d%d%d%d%d) %lx\n",map++,
|
|
int((charData&128?1:0)),int((charData&64?1:0)),int((charData&32?1:0)),int((charData&16?1:0)),
|
|
int((charData&8?1:0)),int((charData&4?1:0)),int((charData&2?1:0)),int((charData&1?1:0)),
|
|
int(charData));
|
|
::OutputDebugString(strString);
|
|
}
|
|
commControl.write(&ack,sizeof(ack));
|
|
break;
|
|
case EventEnd :
|
|
::OutputDebugString("Received end event\n");
|
|
::MessageBox(::GetFocus(),(LPSTR)"Received END event",(LPSTR)"M68HC11",MB_OK);
|
|
reading=FALSE;
|
|
break;
|
|
}
|
|
}
|
|
return TRUE;
|
|
}
|
|
#endif
|
|
|
|
|
|
|
|
// for(index=0;index<wordData;index++)
|
|
// {
|
|
// commControl.read(&charData,sizeof(charData));
|
|
// ::sprintf(strString,"(%d%d%d%d%d%d%d%d) %lx\n",
|
|
// int((charData&128?1:0)),int((charData&64?1:0)),int((charData&32?1:0)),int((charData&16?1:0)),
|
|
// int((charData&8?1:0)),int((charData&4?1:0)),int((charData&2?1:0)),int((charData&1?1:0)),
|
|
// int(charData));
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// if(commStatus.bytesInReceiveQueue())
|
|
// {
|
|
// commControl.read(ioBuffer,sizeof(ioBuffer));
|
|
|
|
|
|
// commControl.clearError();
|
|
// commControl.write(&charByte,sizeof(charByte));
|
|
charByte=0xFF;
|
|
BYTE rcvByte;
|
|
for(int index=0;index<256;index++)
|
|
{
|
|
rcvByte=0;
|
|
commControl.write(&charByte,sizeof(charByte));
|
|
if(commControl.read(&rcvByte,sizeof(charByte)))::OutputDebugString(String(getByteString(rcvByte)+String("\n")).str());
|
|
// charByte++;
|
|
}
|
|
|
|
// charByte='a';
|
|
// commControl.write(&charByte,sizeof(charByte));
|
|
return;
|
|
|
|
|
|
|
|
// commControl.write(&charByte,sizeof(charByte));
|
|
|
|
// if(!commControl.read(&charByte,sizeof(charByte))){mStatusBar->setText("No response to initial command.");return;}
|
|
commControl.write(sndBuffer,sizeof(sndBuffer));
|
|
|
|
// if(!commControl.read(rcvBuffer,sizeof(sndBuffer))){mStatusBar->setText("no data was received from device.");return;}
|
|
// if(!::memcmp(rcvBuffer,sndBuffer,sizeof(sndBuffer)))mStatusBar->setText("The device is present and working properly.");
|
|
// else mStatusBar->setText("Failed to verify write.");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if 0
|
|
#include <m68hc11/commctrl.hpp>
|
|
|
|
int PASCAL WinMain(HINSTANCE /*hInstance*/,HINSTANCE /*hPrevInstance*/,LPSTR /*lpszCmdLine*/,int /*nCmdShow*/)
|
|
{
|
|
CommControl commControl;
|
|
CommStatus commStatus;
|
|
DeviceControlBlock deviceControlBlock;
|
|
BYTE charByte(0xFF);
|
|
|
|
commControl.open(CommControl::PortCOM1);
|
|
if(!commControl.isOkay())return FALSE;
|
|
if(!commControl.setDeviceControlBlock("baud=1200 data=8 stop=1 parity=N"))::OutputDebugString("Set operation failed\n");
|
|
|
|
String strString;
|
|
charByte='a';
|
|
while(TRUE)
|
|
{
|
|
commControl.write(&charByte,sizeof(charByte));
|
|
// commControl.waitForData();
|
|
commControl.read(&charByte,sizeof(charByte));
|
|
::sprintf(strString,"%02x\n",(int)charByte);
|
|
::OutputDebugString(strString);
|
|
charByte++;
|
|
|
|
// commControl.clearError(commStatus);
|
|
|
|
// if(commStatus.bytesInReceiveQueue())
|
|
// {
|
|
// commControl.read(&charByte,sizeof(charByte));
|
|
// ::sprintf(strString,"%02x\n",(int)charByte);
|
|
// ::OutputDebugString(strString);
|
|
// break;
|
|
// }
|
|
::Sleep(250);
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
::OutputDebugString("waiting for break signal...\n");
|
|
commControl.setEventMask(CommControl::EventBreak); // EventBreak
|
|
if(!commControl.waitEvent())::OutputDebugString("timeout waiting for break.\n");
|
|
else ::OutputDebugString("break received, loading code...\n");
|
|
|
|
|
|
BYTE ioBuffer[256];
|
|
|
|
for(int index=0;index<256;index++)ioBuffer[index]=index;
|
|
charByte=0xFF;
|
|
commControl.write(&charByte,sizeof(charByte));
|
|
|
|
// commControl.clearError(commStatus);
|
|
// if(commStatus.bytesInReceiveQueue())commControl.read(ioBuffer,commStatus.bytesInReceiveQueue());
|
|
|
|
commControl.write(ioBuffer,sizeof(ioBuffer));
|
|
::memset(ioBuffer,0,sizeof(ioBuffer));
|
|
|
|
String strString;
|
|
::OutputDebugString("receiving echo\n");
|
|
while(TRUE)
|
|
{
|
|
commControl.clearError(commStatus);
|
|
|
|
if(commStatus.bytesInReceiveQueue())
|
|
{
|
|
commControl.read(ioBuffer,sizeof(ioBuffer));
|
|
for(index=0;index+8<sizeof(ioBuffer);index+=8)
|
|
{
|
|
::sprintf(strString,"%02x %02x %02x %02x %02x %02x %02x %02x\n",
|
|
ioBuffer[index],ioBuffer[index+1],ioBuffer[index+2],ioBuffer[index+3],ioBuffer[index+4],
|
|
ioBuffer[index+5],ioBuffer[index+6],ioBuffer[index+7]);
|
|
::OutputDebugString(strString);
|
|
}
|
|
break;
|
|
}
|
|
::Sleep(1000);
|
|
}
|
|
*/
|
|
return FALSE;
|
|
}
|
|
|
|
#if 0
|
|
for(int index=0;index<256;index++)ioBuffer[index]=index;
|
|
charByte=0xFF;
|
|
commControl.write(&charByte,sizeof(charByte));
|
|
commControl.write(ioBuffer,sizeof(ioBuffer));
|
|
::memset(ioBuffer,0,sizeof(ioBuffer));
|
|
|
|
::OutputDebugString("receiving echo\n");
|
|
while(TRUE)
|
|
{
|
|
commControl.clearError(commStatus);
|
|
if(commStatus.bytesInReceiveQueue())
|
|
{
|
|
commControl.read(ioBuffer,sizeof(ioBuffer));
|
|
for(index=0;index+8<sizeof(ioBuffer);index+=8)
|
|
{
|
|
::sprintf(strString,"%02x %02x %02x %02x %02x %02x %02x %02x\n",
|
|
ioBuffer[index],ioBuffer[index+1],ioBuffer[index+2],ioBuffer[index+3],ioBuffer[index+4],
|
|
ioBuffer[index+5],ioBuffer[index+6],ioBuffer[index+7]);
|
|
::OutputDebugString(strString);
|
|
}
|
|
break;
|
|
}
|
|
::Sleep(1000);
|
|
}
|
|
|
|
#endif
|
|
#endif
|