problem sending code via rs232

M

Martin Petzold

Hi,
i always resolve an "arrow up" instead an "A" when i do this (snipped!):

BYTE Byte;

Byte = 0x41;
PortWrite((BYTE)(&Byte));

BOOL PortWrite (BYTE Byte)
{
WriteFile (hPort, &Byte, sizeof (&Byte), NULL, NULL);
return TRUE;
}

what is the problem?

thx martin
 
A

Alf P. Steinbach

This is off-topic in [comp.lang.c++].

Perhaps try [comp.os.ms-windows.programmer.win32]?

See the FAQ for some other possibilities & posting guidelines.
 
C

Christopher Benson-Manica

Martin Petzold said:
i always resolve an "arrow up" instead an "A" when i do this (snipped!):

What Mr. Steinbach said, and also never multi-post again.
 
E

E. Robert Tisdale

Martin said:
I always resolve an "arrow up" instead an "A" when i do this (snipped!):

BYTE Byte;

Byte = 0x41;
PortWrite((BYTE)(&Byte));

BOOL PortWrite (BYTE Byte) {
WriteFile (hPort, &Byte, sizeof (&Byte), NULL, NULL);
return TRUE;
}

what is the problem?

You don't know what you are doing.

It appears that you are attempting to write the address of a BYTE
which contains the value 0x41.
 
D

David Harmon

This is off-topic in [comp.lang.c++].[/QUOTE]

No it's not. The difference between a char, and the address of a char,
and the address of an array of chars, is not to be ignored in any
standard implementation of C++.
 
B

Bill Thompson

Martin Petzold said:
Hi,
i always resolve an "arrow up" instead an "A" when i do this (snipped!):

BYTE Byte;

Byte = 0x41;
PortWrite((BYTE)(&Byte));

BOOL PortWrite (BYTE Byte)
{
WriteFile (hPort, &Byte, sizeof (&Byte), NULL, NULL);
return TRUE;
}

what is the problem?

thx martin

Assuming that WriteFile requires an address as the second parameter, and a
size as the third parameter, you are writing the size of an address rather
than the size of a byte.

Perhaps this will fix it:
WriteFile (hPort, &Byte, sizeof (Byte), NULL, NULL);
 
H

Howard

Martin Petzold said:
Hi,
i always resolve an "arrow up" instead an "A" when i do this (snipped!):

BYTE Byte;

Byte = 0x41;
PortWrite((BYTE)(&Byte));

PortWrite takes a BYTE, not a pointer to a BYTE, so just pass it Byte, not
the address of Byte.
BOOL PortWrite (BYTE Byte)
{
WriteFile (hPort, &Byte, sizeof (&Byte), NULL, NULL);

If you're intending to write the value stored in Byte, then the size you
probably want is sizeof(BYTE), not the size of the address of the variable.
return TRUE;
}

what is the problem?

thx martin


Perhaps you want this?

PortWrite(Byte);
....
BOOL PortWrite( BYTE Byte )
{
WriteFile( hPort, &Byte, sizeof(BYTE), NULL, NULL );
....
}

?

-Howard
 
R

red floyd

This is off-topic in [comp.lang.c++].

Perhaps try [comp.os.ms-windows.programmer.win32]?

See the FAQ for some other possibilities & posting guidelines.


Aside from the fact that you're OT, you should use "sizeof(Byte)"
instead of "sizeof(&Byte)".
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top