All Forums
 Microsoft Windows CE
 eVC Application Development
 EIO Problem
 Forum Locked
 Send Topic to a Friend
 Printer Friendly
Author Topic  

Patrick

34 Posts

Posted - 26 Aug 2003 :  16:29:56  Show Profile  Email Poster
I'm trying to access two of the "UCB" lines, out of the 10, but I am having trouble with two bits from the middle.
My code is below, based on code provided to me by Chris Tacke, and from the message forum. I thought I was doing the same check on the lines I'm interested in, but #5 and #6 seem to fail.
Thanks,
-Patrick


DWORD WINAPI Thread1(LPVOID lpArg){
HANDLE hDIO;
struct EncoderData ed;
int retval = WAIT_TIMEOUT;
int butval=0;

// For Bitsy+
DWORD data;
DWORD NumberOfBytesRead;
DWORD mask = 0x0000; // All inputs
DWORD NumberOfBytes;

hDIO = INVALID_HANDLE_VALUE;

// open the UCB lines
hDIO = CreateFile(TEXT("EIO1:"), GENERIC_READ, FILE_SHARE_READ,NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if(!(hDIO))
RETAILMSG(TRUE,(_T("Error CreateFile(hDIO)\tLast Error: %d\r\n"),GetLastError()));
if(!DeviceIoControl(hDIO,IOCTL_EIO_CONFIG_PORTS,&mask,sizeof(DWORD),NULL,0,&NumberOfBytes,NULL ))
RETAILMSG(TRUE, (_T("Failed to set EIO direction mask\r\nGetLastError() returned %i"), GetLastError()));

// This loops forever as a thread
while(retval == WAIT_TIMEOUT)
{
ed.StartWeld = -1;
ed.AllStop = -1;
ed.AltScreen = -1;
ed.AGCStop = -1;
ed.WireStop = -1;
ed.Exp1 = -1;
ed.Exp2 = -1;
ed.LED = -1;
// poll the UCB1200 lines
ReadFile(hDIO, &data, sizeof(data), &NumberOfBytesRead, NULL);
DEBUGMSG(TRUE,(_T("Data: %i\r\n"),(int)data));

ed.StartWeld = (data & 1)/1; // UCB 0 - (514) All Stop
ed.AllStop = (data & 2)/2; // UCB 1 - (514) Start/Stop
encoderlinea = (data & 4)/4; // UCB 2 - (514) Encoder A
encoderlineb = (data & 8)/8; // UCB 3 - (514) Encoder B
ed.AltScreen = (data & 16)/16; // UCB 4 - (514) Encoder Button
ed.AGCStop = (data & 32)/32; // UCB 5 - (514) Water Flow
ed.WireStop = (data & 64)/64; // UCB 6 - (514) Gas Flow
ed.Exp1 = (data & 128)/128; // UCB 7 - (514) Axis 1 Fault
ed.Exp2 = (data & 256)/256; // UCB 8 - (514) Axis 2 Fault

// Test lines
butval = ed.StartWeld;
if(butval == -1){
// Do work related to this line
}
butval = ed.AllStop;
if(butval == -1){
// Do work related to this line
}
butval = ed.AltScreen;
if(butval == -1){
// Do work related to this line
}
butval = ed.AGCStop;
if(butval == -1){
// Do work related to this line
// This check FAILS
}
butval = ed.WireStop;
if(butval == -1){
// Do work related to this line
// This check FAILS
}
butval = ed.Exp1;
if(butval == -1){
// Do work related to this line
}
butval = ed.Exp2;
if(butval == -1){
// Do work related to this line
}

// sleep for the interval
Sleep(25);
}

  Topic  
 Forum Locked
 Send Topic to a Friend
 Printer Friendly
Jump To:
Eurotech Support Forums © Eurotech Inc. Go To Top Of Page
This page was generated in 0.03 seconds. Snitz Forums 2000