raw ir remote control

G

Guest

ive created a C# application on a pocket pc which receives raw infrared signals from a remote control into a byte array (using createfile and readfile into the array) but when i use GetValue on an element's contents, its shown as a decimal value up to 255 (1 byte). All the examples Ive seen receive 2 byte hexadecimal numbers which correspond to ir pulses and pauses.
Ive tried combining two 1 byte elements to form one 2 byte element but GetValue returns -1 in decimal after combining two 255 valued elements!
Im trying to find out why (and where) the binary signal is being converted to decimal and if combining 2 elements is the right way to go. I would ideally like a 2 byte hexadecimal signal so that i can follow online examples.
Please help, ive spent ages on this and im running out of time!
 
A

Alex Feinman [MVP]

It would be easier if you posted a code snippet, but here are few things to
keep in mind:
1) short -1 is hexadecimal 0xffff which is exactly what you get by combining
2 byte values set to 255 each (255d = 0xff)
2) You might find it easier to create a memory stream on a byte array that
you received from the IR and then to use BinaryReader to read 8-, 16- or
32-bit values from it.

Rich said:
ive created a C# application on a pocket pc which receives raw infrared
signals from a remote control into a byte array (using createfile and
readfile into the array) but when i use GetValue on an element's contents,
its shown as a decimal value up to 255 (1 byte). All the examples Ive seen
receive 2 byte hexadecimal numbers which correspond to ir pulses and pauses.
Ive tried combining two 1 byte elements to form one 2 byte element but
GetValue returns -1 in decimal after combining two 255 valued elements!
Im trying to find out why (and where) the binary signal is being converted
to decimal and if combining 2 elements is the right way to go. I would
ideally like a 2 byte hexadecimal signal so that i can follow online
examples.
 
G

Guest

thanks for the advice ill try the memoryreader thing.
How do you send 1 bit at a time using writeFile? The parameters it takes seem to work in bytes only. I have found a way of setting a byte to 4 bits using a DCB structure (win API) but it doesn't allow any lower than that.
 
A

Alex Feinman [MVP]

This is not how UART works. You cannot send 1 bit at a time. If you are
trying to emulate consumer remote control I suggest that you read this
article on CodeProject:
http://www.codeproject.com/ce/tvremote.asp

Rich said:
thanks for the advice ill try the memoryreader thing.
How do you send 1 bit at a time using writeFile? The parameters it takes
seem to work in bytes only. I have found a way of setting a byte to 4 bits
using a DCB structure (win API) but it doesn't allow any lower than that.
 
G

Guest

ive read that, unfortunately I don't know C++ although the bit i really need is not there. I understand now that hexadecimal values control the timing of the infrared pulses, however I don't understand how the hexadecimal 2 byte values can be converted to one byte values for using with WriteFile without losing or changing the value. for example 0011 0040 is the hexadecimal for a binary 1 using JVC's protocol (2 bytes for the pulse, 2 bytes for the wait) but i can only send that as 0x00, 0x11, 0x00, 0x40 (1 byte each) and its not working! Can I send something other than a byte with WriteFile?
 

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

Top