I have to control an air conditioner from pc serial port using IR LED, When I am reading the IR data from the serial port It gives nearly 160 characters, But actually my AC remote may send a address+command it may be 8 to 32 bit only. So I would like to know how to decode the IR data using only Serial port. Right now I am using C# code for reading the data. When I am using Terminal also it gives the same data.
The data is as follows:
ððpppððppððpðpðpðpppppppppppppðððpppppppððpððpðppppppppppppppppppppppppppppppppð
ðððøðxpxøøxxøøxøxðxðxppppppxpxpppðøøxxxxxxxøøxøøxøxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xx
This is for ON button..
Please help me....
As a software developer I look at 'what is the intent'. So in this case I wonder if the intent is to control the air conditioner rather than write the code. :-)
If so, you may take the approach of use one of the many home automation products to capture the IR command and have your software trigger that 'saved' command.
"The fastest way to do something is to not do it at all" - Alister Cockburn.
If this is of any interest have a look at these:
http://www.redrat.co.uk/
http://www.usbuirt.com/
http://www.uk-automation.co.uk/products/SQ-IR-%28Infrared%29-Blaster.html
Good luck
Rob
Serial communications are always done at a particular speed, or baud rate. It sounds like you may not be reading the data at the correct baud rate. Do you know what the baud rate is supposed to be?
Looks like the baud rate is incorrect. 9600 is the most common for these kind of devices so make sure your serial port is set to that. Otherwise try all of them out or find some documentation telling you what it is.
Related
I am trying to setup a simple program to a Spellman power supply.
I have setup a serialport object and included a timer to try RS232 connection.
Serial port configuration:
COM4
9600 baud rate
8 data bit
One stop bit
No handshaking is needed for this device.
I am having an issue because I need to send a SPECIFIC string to the Spellman
which I was told this would work:
STX22,pETX
But this does not work, I get no response.
Here is the problem: I have seen other examples, where the Tx or transmit line sends, 22,p^L. The ^L is a special looking character that is smaller and raised. What is this character and how do I send it in C#?
It seems that little character is what I need instead of the ETX part of the string because the hardware responds back.
The cabling works fine -- I shorted the 2 and 3 wire and I get back exactly what I sent in my program.
I have also tried sending it all data in hex instead of ASCII string, and it also does not work.
I also tried using \0002 and \0003 in many different forms for STX and ETX, does not work. I just need to figure out this 22,p^L issue.
Also this 22,p^L I have only seen in LabVIEW programs.
Playing with Windows IoT on a raspberry pi 3 and I am trying to communicate to an Adafruit RFM69HCW.
I have connected to the device via SPI and not matter what I do I can't seem to get the pi to read anything from the device registers.
The one thing I wanted to know is what exactly does SpiDevice.Read(), Write(), TransferSequential() and TransferFullDuplex() do?
I know the obvious basics but I am after the steps it performs for each function.
Reason I ask is because in the spec of the RF module it says when communicating you have to set the CS pin to low, send the command and then set the CS pin back to High. Does, for example, SpiDevice.Read() do this already?
I have been converting both an Arduino library and a Python Raspberry Pi code so I know about doing the Hard Reset first.
Link to the spec if anyone interested.RFM69HCW-V1.1.pdf
Reason I ask is because in the spec of the RF module it says when
communicating you have to set the CS pin to low, send the command and
then set the CS pin back to High. Does, for example, SpiDevice.Read()
do this already?
Yes, you are right. I test the SPIAccelerometer sample and get the following sequence diagram. The yellow line is chip select and the other is clock line. As you can see, when writing and reading the CS is set to low.(The wave shape is ugly because my scope has low performance.)
I am currently iterating through a list of USB Cameras connected to my computer that I retrieved with the following code:
DsDevice[] cams = DsDevice.GetDevicesOfCat(FilterCategory.VideoInputDevice);
I then determine the HardwareID and InstanceID values from the DevicePath for each device, and I look up the following registry key for all devices:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USB{HardwareID}{InstanceID}\
I then read the LocationInformation subkey value. Here are some examples of what I'm receiving based on which USB port the device is plugged in to:
0000.001a.0000.001.003.000.000.000.000
0000.001a.0000.001.004.000.000.000.000
0000.001d.0000.001.008.000.000.000.000
0000.001d.0000.001.007.000.000.000.000
0000.001d.0000.001.005.000.000.000.000
0000.001d.0000.001.006.000.000.000.000
It appears that the second block (index 1 of the returned Split('.') array) is a distinction between the internal USB hub that the USB port is connected to. Is this correct?
I have deduced that the fifth block (index 4) is the USB port number, but on a separate computer I'm using (an Intel Compute Stick), the port number differentiation actually occurs in the fourth block (index 3). Is there a way to know which block I need to check based on the computer? (Third-party libraries are acceptable though I'd much rather use built-in functionality of .NET or straight Windows APIs that I can hook into, if possible.)
Is there any documentation on what each section of the LocationInformation is? I have Googled for information, but I've come up short of what I'm looking for. Perhaps I just don't know the best search terms to find this information. In any case, I'd bet that this documentation could be extremely useful to other StackOverflow users as well.
Thanks!
I have a USB mass storage device that I encrypt with TrueCrypt. When I connect it to Windows, it asks to format. Using TrueCrypt reveals its contents, as expected.
How can I read the first 100 bytes of that device?
I know the bytes will not make sense because they're encrypted but I want to read them in order to create a checksum.
Did this on the top of my head. But is should work.
public static long getBytes(string letter)
{
ManagementObject disk = new ManagementObject(String.Format("win32_logicaldisk.deviceid=\"{0}:\"", letter));
disk.Get();
return long.Parse(disk["Size"].ToString());
}
EDIT: Tested it and changed int to long. It works.
What solutions have you considered so far? Does your application figure out when the USB device is plugged in or unplugged?
As far as I know, there's no native support in .Net for directly accessing USB devices. I had to use libraries such as LibUsbDotNet (http://sourceforge.net/projects/libusbdotnet/) or SharpUSBLib (http://www.icsharpcode.net/OpenSource/SharpUSBLib/) There were pros and cons to both in terms of samples, documentation etc. I am sure you will be able to find what suits you best.
In one case I was able to connect to the device using WMDC, once the connection was established I used OpenNETCF RAPI library to read from / write to the device.
Here's another excellent resource that I had found useful when I wrote an application that needed to interact with a USB device (a barcode scanner).
http://www.developerfusion.com/article/84338/making-usb-c-friendly/
There was a good resourceful discussion to a similar question here on Stackoverflow : Working with USB devices in .NET
The project is as follows;
I would like to create an application that will be able to see packets going to a USB device. When a certain bit of data that is known is sent to the device, the returning data will be intercepted and modified before the application requesting it, gets it. I have used a USB sniffer to see the packets being sent and I know exactly what bits need to be changed. My two questions are;
Is this a possible software solution?
Will this have to be a hardware solution?
Additional Information –
The USB device uses a FTDI245R chip for communication. I know the VID and PID of the device.
I have experience programming in vb.net and C# but I have never done anything with USB
I would like the application to be able to have a number entered and changed to hex data and that is what would be sent to the device. The number being entered would be changed frequently.
Any input is appreciated.
It sounds to me like you want an upper filter driver to the FTDI driver. I don't know what class or type of device you are using or if it has a vendor specific driver or not, but here is a sample that shows how to create an upper filter to a vendor specific driver. This example uses the OSRUSBFX2 device and sample driver in the WDK, you'll want to change the code to work and interface with the FTDI driver instead.