Arduino Leonardo stuck in a loop with infinite keyboard emulation - loops

My Arduino is constantly spitting out keyboard commands after making an accidental error with my code.
Keyboard.write('l');
Now I can't upload any new sketches. I have already tried common Arduino loops solutions like the one from here: How can I "reset" an Arduino board?
The errors I get when trying to upload just before the keyboard starts shooting out code is:
avrdude: stk500_getsync(): not in sync: resp=0x3f
or
avrdude: stk500_recv(): programmer is not responding
It would be great if there is a solution, which wouldn't require buying an external programmer.

Finally fixed it :)
The sync problems were caused due to selecting the wrong board in the compiler.
I was in fact able to overwrite my program as explained in this Stack Overflow question: How can I "reset" an Arduino board?
It did take several attempts to get the timing right, between releasing the reset button and uploading a new program though.

For Arduino Yún users, try uploading via Ethernet/Wi-Fi (menu Tools → Port).

I haven't used a Leonardo myself, but it sounds like the auto-reset may be the problem. Try pressing and holding the reset button, and then (while holding it) upload the sketch.
According to these instructions, you can release the button after the upload has started.

Install ArduinoDroid IDE on the mobile which is available in the play store.
Select the board as Leonardo, connect the Leonardo to the mobile by pressing the reset button on the board and upload the code immediately after removing the thumb on the reset button...
Boom, it worked...
App link: https://play.google.com/store/apps/details?id=name.antonsmirnov.android.arduinodroid2&hl=en

Related

(Monogame) Keyboard input not being recognized

Just got into monogame today. Noticed that my software wasn't taking any keyboard inputs when I tried to bind a key to a fullscreen toggle. Weirdly enough, it takes inputs from my controller just fine, but just not the keyboard. Keyboard.GetState().GetPressedKeyCount() also always returns 0, so I've got no idea what's causing the problem.
I'm not usually one to attach full code files, but the program loop class is only 72 lines, so it's here if it helps: https://pastebin.com/xcWnDvqL
Platform: Windows 10 Build 19044
Monogame Version: 3.8.0.1641 (DesktopGL)
I tried to set up my project the same way as you did, but I am unable to reproduce the issue. It probably has something to do with your system. You can try the following and see if it works for you.
Now this may sound silly, but when you provide input, are you sure the window is active?
Your game can detect input from the gamepad even when the window is inactive, but the same is not true for keyboard input. I noticed this while testing your program. So ensure that the window is active (by clicking on your game window) before pressing a key and see if the game is still unable to detect input.
I hope that this is the problem in your case. If not try the other fixes as shown below.
Update the Monogame packages.
The latest version of monogame available is v3.8.1, so you can update your templates.
Proceed to install the latest nuget templates (as it was mentioned by Monogame that many bugs have been hotfixes in this version. You can do so by doing the following in a terminal.
dotnet new install MonoGame.Templates.CSharp::3.8.1.303
Then proceed to make a fresh desktopgl or mgwindowsdx project and see if the issue persists.
Check for driver issues.
Monogame uses xinput/DirectInput(a package in DirectX) to detect input from the input devices. Maybe the issue has something to do with it. You can search and run dxdiag from the start in windows. Ensure your drivers (including video drivers) are up to date.

[Server]Is it possible to detect power button pressed in a program wrote by ourself in Ubuntu 20.04?

I want to run a program on a server.
But I don't want it shoutdown immediately after I press power button.
The expected result is server could finish program properly and get the test result. Then shutdown finally.
The program running environment would be under the Ubuntu 20.04 Virtual Terminals(TTY).
I have tried some methods on the web I found (like change some system files). But it just disabled the power button function. I can't connect how to detect in my program.
I am curious is it possible to detect power button pressed or not in the program we wrote?
If it is possible, how to do?
Thank you very much!
I would have preferred to comment but I don't have enough reputation.
Have you tried to modify the /usr/share/doc/acpid/examples/powerbtn.sh script?
This page seems to describe how to proceed. But I haven't gone deep.

Is it a good idea to use a Screensaver on a raspberry pi as digital signage?

I asked this question in the Raspberry PI section, so please forgive me for posting this here again. Its just there doesn't seem to be as active as this section of the forum. So, onto my question...
I have an idea and I'm working on it right now. I just wanted to see what the community's thought was on using a screensaver as digital signage. Every tutorial I've read shows someone using chromium in kiosk mode, and while that's fine and works well for some uses, it doesn't work for what I need. I have successfully completed a chromium kiosk, and it was cool. But the signage that I need to create now, has to work without internet. I've thought about installing LAMP locally on the PI, and still using chromium. I still may have to if this idea doesn't pan out. All I need from the signage is a Title Message in the top center, and a message body underneath it, with roughly 300-400 character limit. My idea is to write a screensaver module, in C, that will work with a screensaver such as xscreensaver. The module would need to be able to load messages from a directory on the pi. Then for my clients to update their signage text, I would write a simple client that sent commands as well as the text via SSH to the pi. I want to know what other people think about this. Is it a good idea? Bad idea? Should I "waste" my time doing something like this?
Thanks in advance.
I am already using a rPi as digital signage, just over a year. I am using two different setups:
version 1 uses Raspian loading xdesktop and qiv image viewer to cycle images stored on the Pi itself, synchronized with a remote server. The problem I found was power and SD stability, when the power fails, which it will do no matter what, just when... The Sd card can become corrupt due to all the writing that Raspian does all the time. Certainly does not really need to write to SD.
version 2 uses a RO-filesystem and a command line image tool. Uses the same process to show images from local, and sync with server. But power fail causes no ill effects.
I am not using screensaver to display images, that seemed redundant to me, and unnecessary to wait for the SS to start just to display the images.
Some of the images are created using imagemagik, which is nicely dynamic where needed.

Hook keyboard shortcuts from Windows lock screen

I have an arduino in keyboard emulation mode that sends keyboard keystrokes to the computer it's connected to, the latter appending a log line in a local webpage upon receiving each keystroke. The log program is coded in C using Win32 API.
Now, since it's supposed to function at work (the idea is to get a log file online of when pushbuttons on my desk have been activated), I will be locking my computer...
How can I keep processing CTRL+ALT+key strokes from the windows lock screen?
Thanks,
Mister Mystère
This seems to work: https://www.codeproject.com/Articles/19004/A-Simple-C-Global-Low-Level-Keyboard-Hook
When you run the compiled executable, the keys A and B are detected globally even when the screen is locked.
I ended up downloading a third party lock screen and my program works in its background as it is a standard program. For those of you in the same situation, as far as I know after all that research I'm afraid you'll have to do that instead: it seems like it is not possible starting from Vista.

prevent screen capture

i am developing a video player i silverlight
i wanna something to prevent recording or screen capturing
i thought about hacking the windows APIs and stop my program from running if there was any of those capturing software asking the user to close it first but i donno how to do this
is there another solution ??!!!!
It's simple not possible. If you try it, you're only going to annoy people.
Even 'hacking the windows API' would not work, since the OS itself could be run inside a VM.
I hate to be a downer, but task is impossible to fully accomplish.
If you were somehow able to hook the keyboard (from a silverlight app no-less) I would certainly hope that whatever AV the user is running would throw up some red flags.
Also what if the user doesn't use the standard (alt)+prtscr? A third-party tool might use a different key-combo. Also, I've written a screen-grabber with the GDI+ API, and there's no way to disable something that low-level.
What about attached capture-cards? What if your app is running in a VM or over remote-desktop?
If you are that deeply concerned about protection your HD content, watermark it, or make the user pay for it first.
All-in-all, as soon as your content's data enters your user's computer, they can duplicate it.
You could go about using a key hook system, stopping the user pressing the print screen key on the keyboard, that would be a start. There aren't many systems which stop users from print screening video specifically. You might want to try just watermarking your video instead? At least then people know that the video was originally sourced from you.
The solution is not to allow your application to run on a computer, but instead target a device such as a phone. Computers will always allow some kind of screen capture and video capture but this is much harder and less likely to be tackled if you restrict to only playing on certain devices.
How badly do you need this? There are many ways to defeat screen capture protection: for instance, aiming a video recorder at the computer screen (or looping output to a TV with a capture card, etc. etc. etc.)
Go for a commercial solution if you really really need this: don't have any experience with those myself, however.

Resources