Click here to Skip to main content
16,013,082 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralBitmap to Icon Pin
Jason Hooper10-Mar-03 4:27
Jason Hooper10-Mar-03 4:27 
GeneralRe: Bitmap to Icon Pin
Baris Kurtlutepe10-Mar-03 5:16
Baris Kurtlutepe10-Mar-03 5:16 
GeneralProblem when creating instance of class in case structure. Pin
adapterJohn10-Mar-03 4:00
adapterJohn10-Mar-03 4:00 
GeneralRe: Problem when creating instance of class in case structure. Pin
krism10-Mar-03 4:07
krism10-Mar-03 4:07 
GeneralRe: Problem when creating instance of class in case structure. Pin
adapterJohn10-Mar-03 4:16
adapterJohn10-Mar-03 4:16 
GeneralRe: Problem when creating instance of class in case structure. Pin
Chris Losinger10-Mar-03 4:09
professionalChris Losinger10-Mar-03 4:09 
GeneralRe: Problem when creating instance of class in case structure. Pin
adapterJohn10-Mar-03 4:12
adapterJohn10-Mar-03 4:12 
GeneralComms Problems Pin
TheFox10-Mar-03 1:49
TheFox10-Mar-03 1:49 
I have written a DLL (Win 32) which has been compiled using VC++6 on a Windows 2000 PC. The program that is using the DLL is written in TestPoint (which you probabily won't of heard of) and when I run it on a Windows 98 machine it accesses the COM port correctly.

The problem is that we have just upgraded to a Windows 2000 PC and now the DLL will not work. The DLL is called correctly but no activity on the port occurs (we have checked using a scope).

My DLL code looks like this.

extern "C" _declspec(dllexport) long int BiPhase(int comm_port, int command, int value_1, int value_2 )
{
CComms Comms;

char OutBuffer[5];
char InBuffer[5];

char *pOutBuffer;
char *pInBuffer;

short int tries;

int ierror;
int return_value;

unsigned long Bytes_Avail, timer_loop;

unsigned char Character_0, Character_1, Character_2, Character_3, Character_4;

pOutBuffer = &OutBuffer[0];
pInBuffer = &InBuffer[0];

OutBuffer[0] = 1;
OutBuffer[1] = 7;
OutBuffer[2] = command;
OutBuffer[3] = value_1;
OutBuffer[4] = value_2;
Write the 5 bytes os data using .....
Write to Port
!WriteFile(idComDev, pb, 1, &dummy, NULL)

Read the 5 bytes of Data using ...
Read Port
!ReadFile(idComDev, &szChar, 1, &bytesRead,NULL)

Character_0 = InBuffer[0]; // Not interested
Character_1 = InBuffer[1];
Character_2 = InBuffer[2];
Character_3 = InBuffer[3];
Character_4 = InBuffer[4];

return (Character_2 * 256) + Character_1;


And my Comm port is set up as follows

DCB dcb = { 0 };
dcb.DCBlength = sizeof(dcb);

dcb.BaudRate = 115200;
dcb.ByteSize = 8;
dcb.Parity = NOPARITY;
dcb.StopBits = ONESTOPBIT;
dcb.fBinary = TRUE;
dcb.fRtsControl = RTS_CONTROL_DISABLE;
dcb.fDtrControl = DTR_CONTROL_DISABLE;
dcb.fInX = FALSE;
dcb.fOutX = FALSE;

DWORD dwInQueue = 500000;
DWORD dwOutQueue = 5000;

COMMTIMEOUTS m_TimeOuts;

m_TimeOuts.ReadIntervalTimeout = 30;
m_TimeOuts.ReadTotalTimeoutConstant = 250;
m_TimeOuts.ReadTotalTimeoutMultiplier = 2;
m_TimeOuts.WriteTotalTimeoutConstant = 250;
m_TimeOuts.WriteTotalTimeoutMultiplier = 2;

Set up Port
CString sPort;
sPort.Format(_T("\\\\.\\COM%d"), com_port);

idComDev = CreateFile(sPort, // communication port string (COMX)
GENERIC_READ | GENERIC_WRITE, // read/write types
0, // comm devices must be opened with exclusive access
NULL, // no security attributes
OPEN_EXISTING, // comm devices must use OPEN_EXISTING
FILE_FLAG_OVERLAPPED, // Async I/O
0); // template must be 0 for comm devices


Read Port
!ReadFile(idComDev, &szChar, 1, &bytesRead,NULL)

Write to Port
!WriteFile(idComDev, pb, 1, &dummy, NULL)


Any help would be greatly appreciated.




GeneralRe: Comms Problems Pin
Ted Ferenc10-Mar-03 3:49
Ted Ferenc10-Mar-03 3:49 
GeneralRe: Comms Problems Pin
TheFox10-Mar-03 5:29
TheFox10-Mar-03 5:29 
GeneralRe: Comms Problems Pin
Ted Ferenc10-Mar-03 6:09
Ted Ferenc10-Mar-03 6:09 
Generalto put text on a label field into bold Pin
JensB10-Mar-03 1:39
JensB10-Mar-03 1:39 
GeneralRe: to put text on a label field into bold Pin
Brian Shifrin10-Mar-03 2:09
Brian Shifrin10-Mar-03 2:09 
GeneralRe: to put text on a label field into bold Pin
JensB10-Mar-03 2:15
JensB10-Mar-03 2:15 
GeneralRe: to put text on a label field into bold Pin
Iain Clarke, Warrior Programmer10-Mar-03 3:32
Iain Clarke, Warrior Programmer10-Mar-03 3:32 
GeneralRe: to put text on a label field into bold Pin
Alvaro Mendez10-Mar-03 7:39
Alvaro Mendez10-Mar-03 7:39 
GeneralCreate from resource Pin
Zizilamoroso10-Mar-03 1:31
Zizilamoroso10-Mar-03 1:31 
GeneralRe: Create from resource Pin
Baris Kurtlutepe10-Mar-03 5:25
Baris Kurtlutepe10-Mar-03 5:25 
GeneralProblem with the GetCurrentDirectory function !! Pin
Cris10-Mar-03 0:59
Cris10-Mar-03 0:59 
GeneralRe: Problem with the GetCurrentDirectory function !! Pin
Baris Kurtlutepe10-Mar-03 1:08
Baris Kurtlutepe10-Mar-03 1:08 
GeneralRe: Problem with the GetCurrentDirectory function !! Pin
Cris10-Mar-03 1:36
Cris10-Mar-03 1:36 
GeneralRe: Problem with the GetCurrentDirectory function !! Pin
kirk he10-Mar-03 1:09
susskirk he10-Mar-03 1:09 
Questionhow can i use a straight c function in a C++ program? Pin
kirk he10-Mar-03 0:23
susskirk he10-Mar-03 0:23 
AnswerRe: how can i use a straight c function in a C++ program? Pin
Christian Graus10-Mar-03 0:27
protectorChristian Graus10-Mar-03 0:27 
GeneralRe: how can i use a straight c function in a C++ program? Pin
kirk he10-Mar-03 0:37
susskirk he10-Mar-03 0:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.