Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > problem sending code via rs232

Reply
Thread Tools

problem sending code via rs232

 
 
Martin Petzold
Guest
Posts: n/a
 
      04-12-2004
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
 
Reply With Quote
 
 
 
 
Martin Petzold
Guest
Posts: n/a
 
      04-12-2004
resolve = receive
 
Reply With Quote
 
 
 
 
Alf P. Steinbach
Guest
Posts: n/a
 
      04-12-2004
* Martin Petzold <(E-Mail Removed)> schriebt:
>


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.

--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
 
Reply With Quote
 
Christopher Benson-Manica
Guest
Posts: n/a
 
      04-12-2004
Martin Petzold <(E-Mail Removed)> spoke thus:

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


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

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
 
Reply With Quote
 
E. Robert Tisdale
Guest
Posts: n/a
 
      04-12-2004
Martin Petzold wrote:

>
> 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.





 
Reply With Quote
 
David Harmon
Guest
Posts: n/a
 
      04-12-2004
On Mon, 12 Apr 2004 18:14:56 GMT in comp.lang.c++, http://www.velocityreviews.com/forums/(E-Mail Removed) (Alf
P. Steinbach) wrote,
>* Martin Petzold <(E-Mail Removed)> schriebt:
>>

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


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++.

 
Reply With Quote
 
Bill Thompson
Guest
Posts: n/a
 
      04-12-2004
"Martin Petzold" <(E-Mail Removed)> wrote in message
news:c5elhv$j4e$(E-Mail Removed)...
> 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);



 
Reply With Quote
 
Howard
Guest
Posts: n/a
 
      04-12-2004

"Martin Petzold" <(E-Mail Removed)> wrote in message
news:c5elhv$j4e$(E-Mail Removed)...
> 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


 
Reply With Quote
 
red floyd
Guest
Posts: n/a
 
      04-12-2004
(E-Mail Removed) (Alf P. Steinbach) wrote in message news:<(E-Mail Removed)>...
> * Martin Petzold <(E-Mail Removed)> schriebt:
> >

>
> 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)".
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
VHDL code for RS232 bus controller jasperng VHDL 0 10-08-2008 03:39 PM
Rs232/Usb device via webservices? Is it possible? Marco Savioli Java 0 07-14-2007 12:26 AM
sending <STX><ETX > charaters to RS232 port jyotish.bora@gmail.com C++ 2 01-19-2006 10:06 PM
problem sending code via rs232 Martin Petzold C Programming 4 04-12-2004 08:29 PM
Sending pictures via email Via OE6+Win XP - I no longer get prompt to "make all my pictures smaller" Ian Roberts Digital Photography 3 09-21-2003 04:57 PM



Advertisments