Re: Serial Port Communication in WinCE Emulator using eVC++
Hi,
Many thanks for your quick reply reset-leo.
What i will have to trigger is something like this: http://www.beyondlogic.org/serial/serial.htm
I supose those values are for a desktop PC. If someone known the same values but for PPC, i'll be gratefull.
Ventura
Re: Serial Port Communication in WinCE Emulator using eVC++
if you only want to connect a switch, then (according to the document you sent) you should simply build a loopback plug where you put the switch into the connection between the send- and the receive cable.
i don't know what is your final goal in this, but for testing only, i would suggest to build this loopback device from scratch using a plug and some wires. then leave the ends of the wires connected to the rx and tx pin open (the switch is open) or put the open ends together (the switch is closed).
as i said, and as the document sais, if you put the wire-ends together to close the loop, you should be able to receive what you've sent immediately.
as long as you don't connect any power supplies to some of the pins in your cabeling, there should also be no damage to the com port...
btw: how would you connect to the device? does it offer a sub-d plug on a cradle or will you use the cf-slot? or something else?
Re: Serial Port Communication in WinCE Emulator using eVC++
Well, i'll try to explain the final goal.
I need to develop one dll using evc++. This dll will have to trigger the beavoir of one or to switches connected to my Qteck 2020 throught it's serial port.
I think DTR or CTS have one property like "enable" or "true" which means that some voltage are supplied to that pin.
I think i just have to develop a thread to continually watch some pins.
If the switch is closed, there are voltage. If the switch is open no voltage at that pin.
Something like i found here: http://www.control.com/1026195756/index_html
Clear??? Or not?? :)
Re: Serial Port Communication in WinCE Emulator using eVC++
sorry for the late reply...
through DTR and CTS it may be possible as well. if your switches are connected to that pins (mind the correct voltage as described in the first link you posted!), you could continously call GetCommState() and check the values of the DCB structure.
Re: Serial Port Communication in WinCE Emulator using eVC++
OK,
Many thanks for your replys reset-leo.
Now... another not expected realy BIG PROBLEM.
Unfortunely i was stolen!! My Qtek 2020 has now another owner... Shuinf!! :.(
Forget it!!
Is it possible to simulate the open/close state of the switches in the emulator???
Should i connect the switch to the COM port of my desktop and use it to simulate with de emulator of the evc++???
Will it work??
Many thanks!!!
Ventura
Re: Serial Port Communication in WinCE Emulator using eVC++
Quote:
Originally Posted by V3N7UR4
Is it possible to simulate the open/close state of the switches in the emulator???
Should i connect the switch to the COM port of my desktop and use it to simulate with de emulator of the evc++???
yes, that should work. refer to my very first reply to this thread, where i explain how to configure the emulator to use the pc's com ports.
i would also suggest to put a spell on the evil minded hardware-napper!!!
Re: Serial Port Communication in WinCE Emulator using eVC++
Hi
I am having some problems working with the WinCe emulator.
I need it to communicate over serial interface RS232.
The basic communication works fine, readfile/writefile.
The problem is that I need the functionality of waitComEvent, this works fine with comEventMask set to EV_RXCHAR, but I need the mask to be EV_BREAK.
I cant get this to work, the waitComEvent will not return.
Anybody have any ideas or suggestions?
/switcher
Re: Serial Port Communication in WinCE Emulator using eVC++
Hello,
I using wince 4.2 device terminal, an bluetooth usb adapter and a bluetooth enabled mobile printer device. I am using c#.net, coredll.dll(p/invoke). The mobile printer is running serial port service(standard serial port (SPP)device via bluetooth link).
I want to connect to the mobile printer from the device using bluetooth USB adapter.
I checked the boot peripheral setup settings. There are onboard 3 serial ports and all the three are being used.
OnBoard Serial Port1 2F8h/COM2
OnBoard Serial Port2 3F8h/COM1
OnBoard Serial Port3 3E8h/COM4
Available options for OnBoard Serial Port assignment are:
Auto
Disabled
3F8h/COM1
2F8h/COM2
3E8h/COM3
2E8h/COM4
1) I want to figure out if i can connect from the device terminal to printer using Bluetooth USB adapter on serial port. The device does not support active sync. It does not have any input/output for serial cable. It has two USBs to connect keyboard etc. I am using one of these USB for the Bluetooth USB adapter. There is a scale down version of bluetooth monitor which only allows me to serach the bluetooth devices around and creating a bond. There is not software feature which allows to connect serially to bluetooth enable printer device.
2) From c#.net i make calls to coredll.dll functions CreateFile, WriteFile and ReadFile
CreateFile returns me the handle, but WriteFile returns runtime error 1359(unable to write to COM3).
3) Opening ports and writing on these is second step. I am unable to figure out how to connect to the device to the printer(on serial port).
I used RegisterDevice function call(coredll.dll) and passed the printer address with COM7(no other COM# returns handle). This properly returns an handle.
Please help me.
Thanks and regards,
Gulame
Re: Serial Port Communication in WinCE Emulator using eVC++
hi!
first of all, i don't have any experience in programming for bluetooth devices. but i could imagine that there is some special api for accessing devices in the bluetooth network and would suggest to search msdn for such things.
also, i would search the internet if there are any apis for the usb bluetooth device you are using, or if there is a "virtual com port" driver for your combination of printer/bluetooth enabled device.
Re: Serial Port Communication in WinCE Emulator using eVC++
Hello,
Thanks for your reply and suggestion.
I will search msdn for the api.
If you find any apis, please write to me.
With best regards,
Gulame
Re: Serial Port Communication in WinCE Emulator using eVC++
Hi Reset leo,
I , Santosh kumar here with sending the problem with serial port programming using eVC.
Problem ::
Using CreateFile, SetCommTimeouts, GetCommstate, setCommstate, Writefile.
IDE : EVC 4.0 (witn SP2)
I cant able to read from the other side with Hiperterminal. One PC is running with the application which is written using EVC IDE and communicating with the other PC, which is using hiperterminal.
Project settings :: WINCE Emulator debug
Project is MFC application wizard(EXE)
Re: Serial Port Communication in WinCE Emulator using eVC++
Quote:
Originally Posted by santoshvoonna
Hi Reset leo,
I , Santosh kumar here with sending the problem with serial port programming using eVC.
Problem ::
Using CreateFile, SetCommTimeouts, GetCommstate, setCommstate, Writefile.
IDE : EVC 4.0 (witn SP2)
I cant able to read from the other side with Hiperterminal. One PC is running with the application which is written using EVC IDE and communicating with the other PC, which is using hiperterminal.
Project settings :: WINCE Emulator debug
Project is MFC application wizard(EXE)
hi!
there are a few things you may check:
- is your configuration of the emulator com-ports correct
- you must use a cross-over serial cable (= "null-modem" cable) to connect the two pc's
- you must set the same settings for baudrate, data bits, stop bits and parity in both, you embedded app (setcommstate) and on hyperterminal
i hope this helps.
Re: Serial Port Communication in WinCE Emulator using eVC++
Hi,
Thanks for your quick reply.
- I checked with 2 hipertrminals connected with null modem cable (Working fine)
- I changed the platform manager settings to use COM1
- I am giving the code that I am using ::
void ReadFromCom()
{
// NOTE: setErrMsg sets some error message for the class this code belongs to
HANDLE m_hComm;
// open interface to reader
m_hComm = CreateFile(_T("COM1:"), GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_FLAG_WRITE_THROUGH, NULL);
if (m_hComm == INVALID_HANDLE_VALUE)
{
//setErrMsg("Serial port could not be opened. Wrong port number?");
m_hComm = NULL;
return; // error opening com port
}
else
{
COMMTIMEOUTS noblock;
DCB dcb;
// set communication timeout
GetCommTimeouts(m_hComm, &noblock); // get communication timeouts
// get answer (ReadFile waits for answer until timeout)
// i used this timeouts in this example, because it is easier to handle
// (i do not need any timer)
noblock.ReadTotalTimeoutConstant = 50; // 50 milliseconds timeout
noblock.ReadTotalTimeoutMultiplier = MAXDWORD;
noblock.ReadIntervalTimeout = MAXDWORD;
if (SetCommTimeouts(m_hComm, &noblock) == 0) // set communication timeouts
{
//setErrMsg("Serial port could not be initialized. Error while setting communication timeouts.");
CloseHandle(m_hComm);
m_hComm = NULL;
return; // error opening com port
}
// set communication state
GetCommState(m_hComm, & dcb);
dcb.BaudRate = 9600;
dcb.ByteSize = 8;
dcb.fParity = FALSE;
dcb.StopBits = ONESTOPBIT;
dcb.fDtrControl = DTR_CONTROL_ENABLE;
dcb.fRtsControl = RTS_CONTROL_DISABLE;
if (SetCommState(m_hComm, &dcb) == 0)
{
//setErrMsg("Serial port could not be initialized. Error while setting communication state.");
CloseHandle(m_hComm);
m_hComm = NULL;
return; // error opening com port
}
CHAR pcVersion[20];
DWORD dwByteCount = 0;
#if 0
memset(pcVersion, '\0', 20);
while(1)
{
if (ReadFile(m_hComm, pcVersion, 20, &dwByteCount, NULL) != 0)
{
if(dwByteCount)
{
//Success case
//setErrMsg("Connection to reader established.");
int i;
AfxMessageBox(_T("Connection to reader established."));
i = GetLastError();
i++;
}
}
}
#endif
if(!WriteFile(m_hComm, "S", 1, &dwByteCount, NULL)) // stop the scanmode ????
{
//Failure case
int i;
i = GetLastError();
}
#if 0
ReadFile(m_hComm, pcVersion, 20, &dwByteCount, NULL); // read the firmware version
#endif
if (strncmp(pcVersion, "ISO", 3) != 0)
{
//setErrMsg("An der angegebenen Schnittstelle ist kein Reader angeschlossen.");
CloseHandle(m_hComm);
m_hComm = NULL;
return; // error opening com port
}
}
}
Everything is getting succeeded. But the problem is that I cant able to receive the data at the other PC which is opened with hiperterminal.
- Is there any problem with the code ???
- Do I need to change any preconfiguration settings??
- Can I access serial port using evc and this MFC project ???
Please test it if it is possible for u.
Awaiting yor reply,
Santosh Kumar Voona([email protected])
Re: Serial Port Communication in WinCE Emulator using eVC++
well, the only thing i can imagine is that you may have to set
Code:
dcb.fDtrControl = DTR_CONTROL_DISABLE;
(this is something i did because of the device i am using)
i'm sorry i can't test you code. i'm too busy...
Re: Serial Port Communication in WinCE Emulator using eVC++
Hi Reset Leo,
I tried out all possibilities with the code. But it is not working.
Do I need to install platform builder for serial port communication.
Bye,
Santosh Kumar Voonna.