I have a hardware which connect with my computer via com interface, I want to implement such a feature:
When the button on the hardware is clicked, My application can capture this event and then write something on my application.
So How can I listen to a specific COM interface and capture the event ?
How can I get what command the hardware sent to me ?
You're looking for the System.IO.SerialPort class. It will allow you to open a serial port (a COM port) and read and write data. As for the specifics about how to capture a button press, that would depend entirely on the device. If you know that it sends data over the COM port when a button is pressed, then you just need to know what to expect and you'll be able to capture it.
Related
I am trying to do something every time my iPhone is connected (via USB or wifi). Current alternative is polling list_devices and wait to see my device listed.
Is there something better or polling is the only option?
This is platform independent, but I am testing on Windows
You can subscribe for notifications which are sent by iTunes/usbmuxd whenever a new device is connected. If you're using libimobiledevice, you can use idevice_event_subscribe to register a callback which is invoked whenever a device is added or removed.
I want to register my Application (its a Gtk Application) to receive a signal when the user presses for example the "Next Song" Button, while it is not focused, so the User can change the playback while the Application remains in the background. I have no idea how to do this - will I need to include a specific Library for doing this on Ubuntu 18.04? Just to clarify: I am talking about System-Wide Hotkeys that applications can somehow intercept.
There isn't really a generic mechanism for this in Wayland (the security issues should be pretty obvious); for X, see the XGrabKey function.
For multimedia keys, there is a D-Bus interface you can use at org.gnome.SettingsDaemon.MediaKeys. For an example of how to use it, take a look at plugins/nmkeys/rb-mmkeys-plugin.c in Rhythmbox.
I am working on creating a touch pad device (custom hardware but similar to an android device) that acts as a touchscreen drawing pad similar to the Wacom Bamboo drawing pads. However, the key feature of the device is instead of connecting it to the computer with wires or via Bluetooth, it connects to the local WiFi network and searches for devices with a port open (currently 5000 for testing purposes). Currently, I have a client written in C that when launched opens up a DatagramSocket on port 5000 and waits for a custom UDP packet containing normalized X, Y, and pressure. Then, for testing purposes, I am putting the normalized X and Y into SendInput. SendInput "works" however injecting packets into the computers current mouse is not what I want. Instead, I want to have it considered as a seperate input device so programs like gimp will be able to detect it and assign custom functions based on the data (ie: have gimp utilize the pressure data).
The problem is I dont know where to start to create a driver that does the former. I have been extensively looking at the winddk thinking that might be the key. The problem with the winddk is I cannot find any documentation on creating a HID driver using data that is not from a ps/2 or usb. This tutorial got me thinking about using IOCTLs, but I am not really sure how to make them be considered as input.
As a side note, in the title I said TCP/UDP because I am willing, and considering for security purposes, to change from UDP connection to TCP.
If someone can push me in the right direction or link me to some related documentation and samples, that would be awesome because right now I am lost. Thank you.
I have a windows application on my PC which connects to a device over telnet. It sends a series of commands to the device, and the device responds to it.
Is there any way I can listen to what that program is writing to the device?
I tried using win32 socket programming to create a client that connects to the application. But, I get an error saying connection refused. When I analyze the traffic between the application and device on wireshark, I can see that the application uses different ports each time it reads from or writes to the telnet port(23) of the device.
Is there any way I can read the commands sent by the program to the device?
If you want to capture program's output to the device
programmatically, the right way is not to connect to the program (you
can't tap into an existing connection), but instead provide a server
that will stand for target device from the program's point of view.
It's going to work if the program can be configured to connect to the
device at different address and port. Write a "proxy" that listens on
some fixed port, and for any accepted connection, opens a client
connection to the real device. Then it should forward data in both
directions between the accepted connection from the program and the
client connection to the device. During this, you can also parse data
or do whatever you want with them, e.g. forward them to yet another
connection to another real device.
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