C - detect when an external circuit is closed (button push) [closed] - c

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
I am trying to find out if there is a way for a C console program to detect when an external circuit is closed (e.g. a button is pushed). I have searched for code examples or insight but with no luck.
I know this is easy in arduino/raspberry pi etc. but this will be part of a C console program running on windows.
Ideally the button/switch will be connected by USB or serial.
My current thoughts are to make the switch part of a HID and have it act as a keystroke but this is not my preference.
My preference would be to just close the circuit (short the usb) and have some code that registers when a usb or serial port has a voltage applied but I am not sure if that is possible.
Thank you for your help.

There are several ways of doing this, although you still need external hardware (for example, Arduino).
Via UART - With every Arduino you can communicate via UART/Serial. You will need send data from Arduino to PC when button state changes, and then listen for this data in your C app on computer.
Via HID - For example, Arduino Leonardo (and all other Arduinos with ATmega32U4) have USB Host feature, so you can create your own HID and send data this way, or directly via USB (without HID usage).

15pol game port and 25pol parallel port are able to detect/switch signals, inputs and outputs.
The 15pol game port would be most easy to use, if you still have some.

Related

C - Linux create sound in kernel mode [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I need o write a kernel mode driver that plays a note when a key is pressed. I can capture keystrokes but I have no idea how to play sound from kernel. What do I have to do to play a sound? I am brand new to creating drivers.
I need o write a kernel mode driver that plays a note when a key is pressed.
Why?
Seriously, why. What's the reasoning behind this "need"? What's the true reason for the need to play a sound? Maybe there is a better way.
Assuming a PC, with the pcspkr module loaded, you can of course call its functions. But if you want to play something through the soundcard, you'll essentially have to "open" an ALSA device (inside the kernel), and call its fops, all along while user space may do the same thing.

Redirect messages directed at the GPU [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
Is there anything as low level as that on any Linux distribution? My overall goal is to redirect the message (instruction) meant for the GPU.
That means I would have to be able to program a driver between the CPU and the GPU which redirects any message to where I'd like (like a packet sniffer, but for GPU instructions and one that would stop the info there).
Is there any native Linux support for this kind of thing? Where do I start and what OS is most recommended for this kind of access?
You would need to modify the GPU driver. There you can insert logging or whatever other redirection you have in mind. Since many graphics drivers on Linux are open-source, this should be possible for many graphics cards. But take note that it won't be portable--you'll need to write some separate code for each major variant of GPU you want to support.
If you have something more specific, like that you're trying to capture OpenGL commands, that might make things easier.

Save data in memory on LPC1768 [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I'm trying save data in memory on LPC1768. I want to load data when I put on the microcontroller. I expect data don't erase when I put off the machine.
I'm programming in C. I would need a example code in C but I fount a example code in C++ only: http://developer.mbed.org/users/okano/code/IAP/
Thanks everybody. Bye.
You can write data to the flash on the LPC1768 using the IAP commands documented in the user manual in Chapter 32 "Flash memory interface and programming". Specifically, section 32.8 documents the IAP (In Application Programming) commands that let the program running on the device write to flash. Or you can write to the flash using the ISP (In-System Programming) serial port protocol documented starting in section 32.3.
You can use a tool like Flash Magic or lpc21isp to program using the ISP protocol if you don't want to roll your own.

how to access mouse pointer of remote computer using socket programming? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I'm doing a project on client - server activity monitoring system using tcp/ip protocol, in which i have to access active time details of all client machine from server and server admin could also access mouse pointer and display of any active client machine from server.
i have been done till accessing active time details of all client computer. but i have no idea how to access mouse pointer and display of client machine from server side.
I've been using socket programming on ubuntu and for GUI GTK+3.0 programming. so, please anyone help me how to implement those things and how to program to access mouse pointer and display using socket programming using c?
you can use frame buffering concept, concept used in VNC which allows us to see display of remote machine (generally used in Linux)
Instead of mouse pointer you can store all your system display of client machine into a frame and send it to server and render it on server similar to VNC that will allow you to get display of client.

How do I go about writing a Linux driver for an LCD screen? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I'll start by explaining what I'm looking to do.
I have a BeagleBone Black running Ubuntu 13.04, and this TFT LCD w/touchscreen.
There is a library for the touchscreen that can be used with an Arduino to draw primitive graphics and text on the screen. However, instead of just adapting this library to run on the BeagleBone, I would like to write a driver for this LCD that would allow me to display a GUI created with Qt.
According to Qt's website, embedded Linux applications are written directly the frame buffer.
I have been using this book for reference when writing drivers, but I have not been able to find much information about how the frame buffer works and how it would interact with the LCD driver.
My questions:
Do I have to implement my own frame buffer in order to use Qt to draw a GUI on this screen?
If so, will I have to implement a separate driver for the screen to interact with the frame buffer, or would the frame buffer also handle sending the data to the screen?
Can anyone suggest any examples or reference materials on developing drivers for LCD screens?

Resources