windows: how to stop irda dongle periodic auto detecting - c

I'm writing some code in C for an IrDA project on one win7 32bit computer. I have another computer setup to display any data received via in infrared. This part works. However the as soon as I connect the IrDA dongle to the PC, it starts to send periodic data for searching other IrDA devices. I want to disable this behavior programmatically so I see only the data sends as a result of my code. Anyone know which command to use? Is it WSASetService? I didn't learn socket programming, not sure what "removes from the registry a service instance within one or more namespaces. " really means. http://msdn.microsoft.com/en-us/library/windows/desktop/ms742211%28v=vs.85%29.aspx

Have you disabled the Infrared Monitor Service manually?
I experienced problems with this functionality in win7 when using Windows to communicating with an embedded micro-controller based device that worked well with windows XP.
I disabled the Infrared Monitor Service manually and found that windows was still polling the IrDA periodically!
I have not found any documentation available that describes it or how to disable it, I will continue searching...

Related

Writing a Windows driver for Pro Micro

First off I have very very little experience with how USB functions let alone writing a driver; essentially trying to make this project a learning experience.
My setup consists of the SparkFun Pro Micro board and a Windows machine. I have a potentiometer wired up to the Pro Micro and my end goal is to send the value of the potentiometer to the host machine and use the value to change things like system volume etc...
The Arduino library came with a Serial library and I can send things over USB using that. I currently have a working Arduino program that sends 1 byte every 1 second, and a C program on the windows machine that "connects" to the COM port and reads the byte coming through (this part I have working fine).
The issue is that when the Pro Micro is connected to the computer it appears on a randomly selected COM port and I don't think you can tell which COM ports hold which device (not sure about this bit).
My end goal is when the Pro Micro is connected to the PC the host program should automatically recognize the Pro Micro and start processing the data that is coming from it. Setting it up as a HID device and making it appear in Device Manager as my own custom device is something I'd be interested in doing, especially for the learning experience but I feel that it might overcomplicate things.
Can anyone point me in the right direction as to what I should do/look into?
maybe use windows internal tools like the COM port database (https://msdn.microsoft.com/en-us/library/ff546481.aspx) or re-assign COM ports using windows registry, see
How does windows map the virtual com port to a device
https://superuser.com/questions/851192/change-com-port-number-programmatically
http://www.ftdichip.com/Support/Documents/AppNotes/AN_132_Re-Assigning_COM_Port_Numbers_Using_Registry.pdf
if you want to know the backgrounds: the arduino implements the USB CDC ACM class (Communication Device Class - Abstract Control Model https://en.wikipedia.org/wiki/USB_communications_device_class) and emulates a COM port. Windows recognizes this class and loads the apropriate driver which is usbser.sys (https://msdn.microsoft.com/de-de/library/windows/hardware/dn707976%28v=vs.85%29.aspx) when the driver is loaded the new (virtual) COM port is accessible
the best sources are How does windows map the virtual com port to a device, https://superuser.com/questions/851192/change-com-port-number-programmatically and http://www.ftdichip.com/Support/Documents/AppNotes/AN_132_Re-Assigning_COM_Port_Numbers_Using_Registry.pdf
I would suggest using libusbp, a C library that can be used to find the name of a COM port, given the USB vendor ID and product ID. There is even an example in the "examples" folder that does just that:
https://github.com/pololu/libusbp

Bluez, multiple GATT servers running on the same computer

In other socket applications you can’t open a port that is already in use but bluetoothd seems to accept several listening GATT servers running in parallel, how is that possible?
I try to setup a GATT server using bluez 5.35 on Raspberry Pi Jessie. I have made an application that starts the GATT server much like the example btgatt-server.c using l2cap socket. I have a custom characteristic that a client application can connect and use. I have also setup to enable advertising using hci commands (it is set to enable just after listen() command on the socket).
I have done so the application auto start in rc.local. My problem is that after reboot, sometimes I don't see my own characteristics but I get a complete other list of services/characteristics. If I don’t start my own application and only enable advertising (sudo hciconfig hci0 leadv) I see the same list so it seems to be running a GATT server by default.
What mechanism in bluez decide if my services/characteristics or the other ones (I guess loaded by default plugins) are visible? They are never combined and visible at the same time and I don’t see any error messages during my application startup even if I can’t see the characteristics from the client and don’t get anything by accept(). How can I be sure my characteristics is always visible?

Embedded System Hangs

I am using TIOMAP/AM3517 based custom board which has ARM7 core + Linux 2.6.32 running on it.
Recently, I started observing an issue in which all the interfaces serial console, RNDIS/USB, Network stops responding (my type on keyboard connected to serial port/console port doesn't go through + no device is detected upon removal/insertion of USB sticks/BT dongle + Ethernet/network activities are stopped (can't login over ssh or access webPage that the system has.
I checked the power to the CPU and other power rails using DMM and it looks fine.
There is no keyboard attached so MagicSysRq cannot be used while the issue happens.
I have watchdog on the system which rebooted the system, however to reproduce the issue and to get more information of the system's state, now i have disabled the watchdog.
Finally, my system/linux is configured to reboot upon detecting softlockup which is not happening either. Also, I have enabled verbose debug options under kernel hacking but nothing seems to give any more information.
How do I debug the issue to identify the rot cause of it?

ANSI C on Windows 7 - Programmatically generating a Serial Event (RS232)

I am using a combination of hardware and virtual serial ports in a ANSI C Windows 7 environment. In this project, there will be two applications: The first application is being developed and will be connected both to a hardware COM port and to a virtual COM port. The second is a legacy application (has already been developed and cannot be changed) It will be connected only to the same virtual COM port via a virtual NULL modem.
In the first application, COM event handlers can be used for listening to and handling messages generated from a serial message generator connected to the hardware COM port. However, virtual COM ports do not generate COM events, and so I am limited to using timing loops to periodically check the simulated in and out queues of the virtual port. This is fine for controlling COM traffic in the first application, but the second application will need to see a COM event to enable it to process incoming serial traffic.
Is there a way to generate Windows COM (RS232) events programmatically in one application such that a legacy application that is expecting COM events, can see them?
By events, I am referring to those recognized by a typical comcallback, such as:
LWRS_RXCHAR, LWRS_RXFLAG, LWRS_TXEMPTY, LWRS_CTS, etc.
I don't know if this will work, but you can try to make a loopback on the legacy COM interface? Then you can write to it and it will trigger COM events.
Just closing the loop here (a little late), Thanks for the attempt #Evert.
The solution was to select the right vendor. We needed a good kernel mode driver to produce the right configuration of virtual com port. Eltima (www.eltima.com) provided a product that did just that. Great product with a usable API. Problem solved

Alternative to SendKeys when running over Remote Desktop?

I have an application which injects keystrokes into applications via SendKeys.
Unfortunately, the application will not work when I am running it via Remote Desktop
because of the well known issue that SendKeys doesn't work with Remote Desktop.
Has anyone solved this issue before, or have any good suggestions on how to resolve it?
SendKeys is not a good fit mainly due to:
It can only send keys to active/focused application, which is never guaranteed to work because the the active application can change between the time the keys are actually sent.
RDP and many other libraries (e.g., DirectX) block them mainly for security reasons.
Better alternatives:
Use SendMessage or SendInput for simple needs
Some good examples of how to use SendMessage can be found:
Send strings to another application by using Windows messages
SendMessage via pInvoke
How To Send Keystrokes To Extern Win Application
For more elaborate needs, it is recommended to use WCF
To get you started, read this Basic Tutorial that talks about Inter Process Communication
Sample code using SendMessage:
HWND hwndNotepad = FindWindow(_T("Notepad"), NULL);
HWND hwndEdit = FindWindowEx(hwndNotepad, NULL, _T("Edit"), NULL);
SendMessage(hwndEdit, WM_SETTEXT, NULL, (LPARAM)_T("hello"));
In my case I was successfully using WinAPI's SendInput with hardware scan codes. It seems like SendKeys maps chars to scan codes incorrectly.
You can workaround RDP issue by having desktop always logged in before use (or configured for auto-login # every boot).
And even with the auto-login, if you ever need remote desktop access to run automation, or manage system, etc., the preferred method is using VNC for remote access rather than RDP. Reason is VNC is cross platform and you won't run into this RDP issue. VNC works like a relay of your actual desktop (RDP console session 0 or the "head" of the machine), the disadvantage being one remote session at a time only (or you all share the same desktop + keyboard + mouse). VNC will work for virtual machines too. Use VNC instead of RDP or local (RDP) access from the (VMWare/Hyper-V/Xen) virtual machine manager software.
The only thing to watch out for with VNC still is that the desktop not be configured to auto-lock on idle or screensaver, that may also stop send keys and GUI automation from running, so be sure to disable that. Screensaver & monitor power save is ok, just no auto-lock & password protect.
NOTE: I'm not sure, but believe since VNC relays the desktop "as is", it is the same as executing locally from the app/system's point of view, so it should in theory also be able to fool the system/app that doesn't allow SendKeys via RDP. I've had no issues using this VNC method for AutoIt + SendKeys, whether I was actively connected via VNC, or disconnected (sendkeys/automation still continues to work after disconnect because on the actual desktop, it's still logged in, just that VNC not active).
In my case I was using sendkeys as part of test automation. It would not work from my build machine, where the build agent runs through remote desktop protocol. I'm not happy about it but I was able to skip that test as part of my automated builds.
Using Win32 calls to send window messages might work, if I have time I may try that someday.
Anyhow, here is the check to see if the current code is running in a remote desktop session:
System.Environment.GetEnvironmentVariable("SESSIONNAME").StartsWith("RDP-")

Resources