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.
Re: Serial Port Communication in WinCE Emulator using eVC++
your code seems all right. still, i think that something in your hyperterminal configuration might be wrong.
did you already step through your code using the debugger? if writefile is executed without errors, then it's likely that there is a problem with the hyperterminal. you could also try using a terminal program which is capable of showing hex-formatted data (check out http://www.der-hammer.info/terminal/). maybe something is corrupted while communication and hyperterminal can't display it... that's only speculations.
on my machine, it works without platform builder.
Re: Serial Port Communication in WinCE Emulator using eVC++
Hi Leo,
Here in my machine, i selected com1 for emulator configuration settings.
When wince emulator is coming up it is wrting some data in to com port. But if I execute my program WriteFile is getting succeeded by setting the number of bytes written to proper value. But at the other side it is not displaying anything.
Please let me know if any preconfiguration settings are required for this. Please give your mail id if there is no problem, so that I can send my entire project to there.
Regards,
Santosh Kumar Voonna.
Re: Serial Port Communication in WinCE Emulator using eVC++
Hi Leo,
Here in my machine, i selected com1 for emulator configuration settings.
When wince emulator is coming up it is wrting some data in to com port. But if I execute my program WriteFile is getting succeeded by setting the number of bytes written to proper value. But at the other side it is not displaying anything.
Please let me know if any preconfiguration settings are required for this. Please give your mail id if there is no problem, so that I can send my entire project to there.
Regards,
Santosh Kumar Voonna.
Re: Serial Port Communication in WinCE Emulator using eVC++
Quote:
Originally Posted by santoshvoonna
Hi Leo,
Here in my machine, i selected com1 for emulator configuration settings.
When wince emulator is coming up it is wrting some data in to com port. But if I execute my program WriteFile is getting succeeded by setting the number of bytes written to proper value. But at the other side it is not displaying anything.
Please let me know if any preconfiguration settings are required for this. Please give your mail id if there is no problem, so that I can send my entire project to there.
Regards,
Santosh Kumar Voonna.
try to set the emulator com port 1 to "file:" and see if something is written then. if that works, there must be something wrong in the serial port configuration settings you specify in hyperterminal.
still, i'm quite sure that there actually IS something wrong with those settings. maybe you could post a screenshot of the hyperterminal properties-screen?
don't be angry, but i don't have the time to debug your project...
1 Attachment(s)
Re: Serial Port Communication in WinCE Emulator using eVC++
Hi Leo,
Since this is the fist time, I am not sure whether the way I am creating and executing the application is correct or not. Anyhow I am explaining the way I am creating the project and executing it. Please check and let me know if there is any problem in the process.
- Creating empty MFC project(Document based).
- Creating one menu item (ConfigAndReadFromComm) using resource.
- Adding the code as a handler for the menu item
- Building the project (With WINCE emulator debug option)
- Directly executing.
- Main thing is that every API is returning success and Write file is setting no of bytes written correctly.
- If I configure the platform mgr com settings to COM1
Whenever WINCE .NET image is coming up some data it is writing to comm port. Same behaviour I can observe if I click/move my mouse pointer on the document of the WIN CE application. Some data which i cant able to understand at all
- Finally
If I set the serial conf option to "file:" then I can see some statements over there. But those statements also I cant able to understand. Please look at the first few lines of the file
Debug Serial Init
SysInit: GDTBase=808b0040 IDTBase=808b94a0 KData=808c1800
Windows CE Kernel for i486 Built on Dec 16 2001 at 18:18:13
g_PageDir = 808c2000
RTC - Status Reg B - 0x02
X86Init done.
Checking if CPU = emulator...
Yes - CPU = emulator
Checking if CPU = emulator...
Yes - CPU = emulator
SENDING command id 0xE100 to CWinApp target.
SENDING command id 0xE100 to CWinApp target.
SENDING command id 0xE101 to CWinApp target.
SENDING command id 0xE103 to CSerTest4Doc target.
No handler for command ID 0xE123, disabling it.
No handler for command ID 0xE122, disabling it.
No handler for command ID 0xE125, disabling it.
SENDING command id 0xE140 to CWinApp target.
SENDING command id 0xE100 to CWinApp target.
SENDING command id 0xE101 to CWinApp target.
SENDING command id 0xE103 to CSerTest4Doc target.
No handler for command ID 0xE123, disabling it.
No handler for command ID 0xE122, disabling it.
No handler for command ID 0xE125, disabling it.
SENDING command id 0xE140 to CWinApp target.
SENDING command id 0xE100 to CWinApp target.
SENDING command id 0xE101 to CWinApp target.
SENDING command id 0xE103 to CSerTest4Doc target.
No handler for command ID 0xE123, disabling it.
No handler for command ID 0xE122, disabling it.
No handler for command ID 0xE125, disabling it.
SENDING command id 0xE140 to CWinApp target.
SENDING command id 0xE100 to CWinApp target.
SENDING command id 0xE101 to CWinApp target.
Awaiting your reply.
Regards,
Santosh Kumar Voonna.
Re: Serial Port Communication in WinCE Emulator using eVC++
santosh, i'm sorry that i have to say that i have no idea of what could be wrong except that you could still be having a problem in the communication settings of hyperterminal... i still got no information from you on which settings you are actually using!
Re: Serial Port Communication in WinCE Emulator using eVC++
Hi Leo,
Since this is the fist time, I am not sure whether the way I am creating and executing the application is correct or not. Anyhow I am explaining the way I am creating the project and executing it. Please check and let me know if there is any problem in the process.
- Creating empty MFC project(Document based).
- Creating one menu item (ConfigAndReadFromComm) using resource.
- Adding the code as a handler for the menu item
- Building the project (With WINCE emulator debug option)
- Directly executing.
- Main thing is that every API is returning success and Write file is setting no of bytes written correctly.
- If I configure the platform mgr com settings to COM1
Whenever WINCE .NET image is coming up some data it is writing to comm port. Same behaviour I can observe if I click/move my mouse pointer on the document of the WIN CE application. Some data which i cant able to understand at all
- Finally
If I set the serial conf option to "file:" then I can see some statements over there. But those statements also I cant able to understand. Please look at the first few lines of the file
Debug Serial Init
SysInit: GDTBase=808b0040 IDTBase=808b94a0 KData=808c1800
Windows CE Kernel for i486 Built on Dec 16 2001 at 18:18:13
g_PageDir = 808c2000
RTC - Status Reg B - 0x02
X86Init done.
Checking if CPU = emulator...
Yes - CPU = emulator
Checking if CPU = emulator...
Yes - CPU = emulator
SENDING command id 0xE100 to CWinApp target.
SENDING command id 0xE100 to CWinApp target.
SENDING command id 0xE101 to CWinApp target.
SENDING command id 0xE103 to CSerTest4Doc target.
No handler for command ID 0xE123, disabling it.
No handler for command ID 0xE122, disabling it.
No handler for command ID 0xE125, disabling it.
SENDING command id 0xE140 to CWinApp target.
SENDING command id 0xE100 to CWinApp target.
SENDING command id 0xE101 to CWinApp target.
SENDING command id 0xE103 to CSerTest4Doc target.
No handler for command ID 0xE123, disabling it.
No handler for command ID 0xE122, disabling it.
No handler for command ID 0xE125, disabling it.
SENDING command id 0xE140 to CWinApp target.
SENDING command id 0xE100 to CWinApp target.
SENDING command id 0xE101 to CWinApp target.
SENDING command id 0xE103 to CSerTest4Doc target.
No handler for command ID 0xE123, disabling it.
No handler for command ID 0xE122, disabling it.
No handler for command ID 0xE125, disabling it.
SENDING command id 0xE140 to CWinApp target.
SENDING command id 0xE100 to CWinApp target.
SENDING command id 0xE101 to CWinApp target.
Awaiting your reply.
Regards,
Santosh Kumar Voonna.
Re: Serial Port Communication in WinCE Emulator using eVC++
Hi,
I have some problems with my WinCe Pocket PC PDA: I must connect a USB device to the PDA to get some information from it by sending an AT command and reading the response.
The first problem is that the USB device manufacturer provides several driver DLL's and I am not sure which is the correct one for my iPAQ (ARM, MIPS, PPC, SHx and x86 are the possibilities, I have chosen PPC, 403 instead of 821, two more possibilities, but I don't really know about them).
Once I have copied the DLL to the PDA '/Window' directory, I plug in the USB device to the PDA and a dialog is supposed to appear to ask me for the DLL the PDA needs, the one copied before. No dialog appears, the PDA seems not to recognize the USB device, should it show anything when you plug in a USB device? May it be because the USB device need some power supply that the PDA can not give?
Another problem is to access to the COM port, I have installed a 'registry manager' and the USB serial port seems to be 'COM5:', so use the code given here to access to this port in CreateFile.
In the code appears:
-------------------------------------------------------------------------------------
CHAR pcVersion[20];
memset(pcVersion, '\0', 20);
DWORD dwByteCount = 0;
if (ReadFile(m_hComm, pcVersion, 20, &dwByteCount, NULL) != 0)
{
setErrMsg("Connection to reader established.");
}
WriteFile(m_hComm, "S", 1, &dwByteCount, NULL); // stop the scanmode ????
ReadFile(m_hComm, pcVersion, 20, &dwByteCount, NULL); // read the firmware version
-------------------------------------------------------------------------------------
The message "Connection to reader established" appears, but dwByteCount = 0. I have tried to modify the code to send an AT command and read the response:
------------------------------------------------------------------------------------
int writeOK = WriteFile(m_hComm, _T("at+L4"), 4, &dwByteCount, NULL);
int readOK = ReadFile(m_hComm, pcVersion, 4, &dwByteCount, NULL);
------------------------------------------------------------------------------------
writeOK != 0 (so it writes ok, doesn't it?) and dwByteCount = 4
readOK != 0 but dwByteCount = 0, so no data is read!!!!
I don't know if my PDA recognizes the USB device, if it can open the USB port and write but not read, or the device is not recognized and the write is wrong, so no read is possible...
I have installed the vxHpc in the PDA, and connected it to the USB port. I have tried to write something to see the response, but nothing seems to happen when I use the keyboard (nothing on screen and the cursor does not move!!!)
I would be greatful with any help, 'cause I am really stuck on it...
Thanks in advance