473,480 Members | 2,967 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

signal RTS and port COM...

hi,

i want send strings by a port COM and put the RTS signal to 1 before send,
and put it to 0 after send the last caractere. A extract of my code:

DWORD dwEvtMask;
char *bufferS = "toto";

hPort = CreateFile
( "COM1", GENERIC_WRITE|GENERIC_READ,0, NULL, OPEN_EXISTING,
FILE_FLAG_OVERLAPPED, );

SetCommMask(hPort, EV_TXEMPTY)

overloppedAttEnvoi.hEvent = CreateEvent(NULL, true, 0, NULL);
overloppedAttEnvoi.Internal = 0;
overloppedAttEnvoi.InternalHigh = 0;
overloppedAttEnvoi.Offset = 0;
overloppedAttEnvoi.OffsetHigh = 0;

overloppedEcri.hEvent = CreateEvent(NULL, false, 0, NULL);
overloppedEcri.Internal = 0;
overloppedEcri.InternalHigh = 0;
overloppedEcri.Offset = 0;
overloppedEcri.OffsetHigh = 0;

EscapeCommFunction(hPort,SETRTS)

WriteFile(hPort, bufferS, nbCharAEcrire, &nbCharEcrit, &overloppedEcri)

WaitCommEvent(hPort, &dwEvtMask, &overloppedAttEnvoi)
iLastErr = GetLastError();
if (iLastErr != ERROR_IO_PENDING)
printf ("Probleme! %i\n",iLastErr);
else
{
rap = WaitForSingleObject(overloppedAttEnvoi.hEvent, 1000);
switch (rap)
{
case WAIT_OBJECT_0:
if (!GetOverlappedResult(hPort, &overloppedAttEnvoi, &nbCharEcrit, false))
{
iLastErr = GetLastError();
if (iLastErr == ERROR_IO_INCOMPLETE)
printf("%s %d","Operation incomplete",iLastErr);
else
printf ("Error : %x et rap : %d\n" , GetLastError(),rap);
}
else
{
ResetEvent(overloppedAttEnvoi.hEvent);
EscapeCommFunction(hPort,CLRRTS) }break;
default:
printf ("Error : %x et rap : %d\n" , GetLastError(),rap);
}
}
Normaly i put RTS to 0 when the last caractere sent, but NO!
RTS down low at the midle of my string!!!

Help me please to resolve this problem

Thanks.
Nov 17 '05 #1
3 1234
> Normaly i put RTS to 0 when the last caractere sent, but NO!
RTS down low at the midle of my string!!!

Help me please to resolve this problem


There is no solution of your problem, if you want to do it by hand.

The problem is that the EV_TXEMPTY event is received, *before* the last
character has really left the seriel port!

EV_TXEMPTY is only a signal that your can not put some more data into the
serial-chip´s buffer!
The problem is that the documentation on this point is wrong:
<quote>
EV_TXEMPTY: The last character in the output buffer was sent.
</quote>

You can verify this by checking the serial-driver example in the DDK
(which is (almost) the same as the RTM version).

The only solution is to use the "RTS_CONTROL_TOGGLE" feature of the
serial-driver!
This does exactly what you want!
--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/
Nov 17 '05 #2

The only solution is to use the "RTS_CONTROL_TOGGLE" feature of the
serial-driver!
This does exactly what you want!


Yes, it's true for XP but not for WIN98 or 2000!!!

My problem is my program must run over multiple OS : WIN98 ==> XP.

I have a big problem....
Nov 17 '05 #3
=?Utf-8?B?bGFtYWxpY2U=?= wrote:
I have a big problem....


Yes.

--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/
Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
3681
by: Elf M. Sternberg | last post by:
I'm having a devil of a time with signal handling under BSD 4.4 with Python and I was hoping that this might ring a bell with someone. Using the Webware Application Server (a multi-threaded Python...
0
7505
by: Stephane Raimbault | last post by:
I've been searching the mailing list for a solution to my problem with "mysqld got signal 11;" and I haven't seen any answers that might help me. This is the situation. I have a db that is being...
4
3830
by: Ollie Cook | last post by:
Hi, I am having some difficulty with read(2) and interrupting signals. I expect I am misunderstanding how the two work together, so would appreciate some guidance. I am trying to 'time out' a...
11
2922
by: Jackie | last post by:
Hi everyone, I'd like to know when and how signals are used (e.g. SIGFPE, SIGABRT, SIGTERM, SIGSEGV, SIGINT)? Thank you so much.
2
3652
by: sai bo shan via DotNetMonster.com | last post by:
hi, all how can i send strobe signal from parallel port? please help me! thanks, Cyber Clone
2
1924
by: sai bo shan via DotNetMonster.com | last post by:
hi, all i want to know about strobe signal output from parallel port. i want to use parallel port without inpout32.dll. how can i do it? thanks. -- Message posted via...
13
3093
by: Christopher Cashell | last post by:
Yesterday, while attempting to access a database, I received errors saying that the database was innaccessible. After investigating a little, I found the following in the PostgreSQL log files: ...
2
1471
by: hg | last post by:
Hi, I posted an equivalent question earlier ... but am still not sure: I currently (under Linux) have a program that uses Queue.put (raw_input('')) in a signal handler and Queue.get() in the...
0
1560
by: JNL via DotNetMonster.com | last post by:
hi guys! i need help on how to read signals from pins 10 and 12 of the parallel port do i need to add a reference or a COM component to read signals from the pins? all i need to do is get a...
1
6735
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
6895
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5326
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4770
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
2992
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
2977
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1296
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
558
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
176
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.