0

To send a serial string character to the serial port. I would need to call WriteFile(handle, "A", strlen("A"), ...)

However, what if I want to specify and send a hex or binary number? For example, I want to send WriteFile(handle, 0x41, sizeOf(0x41), ...) ?

Is there a function that allow me to do this?

2 Answers 2

1

If you just want to write one byte, it still needs to be in an array.

So you would need:

int buffer[1024];
buffer[0] = 42;

WriteFile(handle, buffer, 1);

See this: http://msdn.microsoft.com/en-us/library/aa365747(VS.85).aspx

0

There are many ways.

The most straight forward for you though would be WriteFile( handle, "\x41", 1 ... );

The strlen() is redundant, since you know the length.

1
  • While you are correct in answering his question, it may not have extended Steve's knowledge. By using "\x41" you did not explain this is actually an array of char. Steve is lacking the understanding that you need to feed an array into this method. Nov 14, 2008 at 1:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.