Hardware Simulation - hardware

I'm working on a software project intended for recuperating old specific hardware, mostly for non-for-profit organizations and poor schools.
I need a way to simulate old hardware so I can test the application before shipping it out.
How can I do this?

I'm not sure exactly what the question is asking for. I think you are asking for a way to emulate certain HW?
If that is the case, I've used QEMU in the past, and it has worked great. QEMU is an open source machine emulator and virtualizer.

Use virtual machines? Prepare the images reflecting (more or less) the state of the target machines (speed, hardware, etc). And use them for testing the deployment?

You might want to check out Emulator Zone, and emulator is a good google search term you might not have tried.

Well. If the old hardware is communicating via RS232, then write a class that wraps the RS232 commands and make the class inject the messages the old hardwares would respond. In your program, work against that class instead of real rs232-port and just change instance to real rs232 before shipping.
I have done this succesfully in a project and it worked out really good and its not that complicated that you can think.

Related

needed : Program for easily switching developer environment

This might be the wrong forum, but its filled with so many smart people so someone might know a solution.
One of my customers has given me several assignments that require a quite similar yet wery different development setup (different versions of class-libraries and such) and the problem is that each time I need to switch between the projects I need to do a lot of configuring to get the compilation to work and not include wrong versions of tools used.
If I dont get it right there might be a lot of cleanup afterwards.
It takes me at least an hour to switch projects. Often several.
Now I realize that the customer has an issue with a lot of branching in their setup and they are working on that, but thats a long process.
So.. My question is. Is there some tool that allows me to take "snapshots" of working project-environments and switch between them?
I'm working on windows.
There are many options. One of them is virtualization: running an entire operating system on top of your operating system. It will emulate a fake hard drive, fake network card, etc. This will run an entire desktop 'in a box'.
In the last years containerization is very popular: running a separate environment (file system, OS configuration) but leaving the heavy stuff to the host (in your case, Windows) such as networking, hardware, etc. This is geared towards running a single application (though this is flexible) 'in a box'.
In your case, since you need to encapsulate an entire development environment, it would seem to be best to go with a virtual machine.
A no-cost solution is Virtualbox. Paid alternatives such as VMWare may offer better usability, performance or features.
If your class libraries are in a specific location, you could containerize the compiler: you work on your PC, then build inside of a 'box' with its own environment. Docker is often used.
Depending on what language you are programming in, there may be a specific solution. Python has VirtualEnv, for example.

Applying Non-Standard Power Assertions & Creating Virtual HIDs

I've got a big ask here, but I am hoping someone might be able to help me. If there's another site you think this should be posted on, please let me know.
I'm the developer of the free app Amphetamine for macOS and I'm hoping to add a new feature to the app - keeping a Mac awake while in closed-display (clamshell) mode while not having a keyboard/mouse/power adapter/display connected to the Mac. I get requests to add this feature on an almost daily basis.
I've been working on a solution (and it's mostly ready) which uses a non-App Store helper app that must be download and installed separately. I could still go with that solution, but I want to explore one more option before pushing the separate app solution out to the world.
An Amphetamine user tipped me off that another app, AntiSleep can keep a Mac awake while in closed-display mode, while not meeting Apple's requirements. I've tested this claim, and it's true. After doing a bit of digging into how AntiSleep might be accomplishing this, I've come up with 2 possible theories so far (though there may be more to it):
In addition to the standard power assertion types, it looks like AntiSleep is using (a) private framework(s) to apply non-standard power assertions. The following non-standard power assertion types are active when AntiSleep is keeping a Mac awake: DenySystemSleep, UserIsActive, RequiresDisplayAudio, & InternalPreventDisplaySleep. I haven't been able to find much information on these power assertion types beyond what appears in IOPMLibPrivate.h. I'm not familiar at all with using private frameworks, but I assume I could theoretically add the IOPMLibPrivate header file to a project and then create these power assertion types. I understand that would likely result in an App Store review rejection for Amphetamine, of course. What about non-App Store apps? Would Apple notarize an app using this? Beyond that, could someone help me confirm that the only way to apply these non-standard power assertions is to use a private framework?
I suspect that AntiSleep may also be creating a virtual keyboard and mouse. Certainly, the idea of creating a virtual keyboard and mouse to get around Apple's requirement of having a keyboard and mouse connected to the Mac when using closed-display mode is an intriguing idea. After doing some searching, I found foohid. However, I ran into all kinds of errors trying to add and use the foohid files in a test project. Would someone be willing to take a look at the foohid project and help me understand whether it is theoretically possible to include this functionality in an App Store compatible app? I'm not asking for code help with that (yet). I'd just like some help determining whether it might be possible to do.
Thank you in advance for taking a look.
Would Apple notarize an app using this?
I haven't seen any issues with notarising code that uses private APIs. Currently, Apple only seems to use notarisation for scanning for inclusion of known malware.
Would someone be willing to take a look at the foohid project and help me understand whether it is theoretically possible to include this functionality in an App Store compatible app?
Taking a quick glance at the code of that project, it's clear it implements a kernel extension (kext). Those are not allowed on the App Store.
However, since macOS 10.15 Catalina, there's a new way to write HID drivers, using DriverKit. The idea is that the APIs are very similar to the kernel APIs, although I suspect it'll be a rewrite of the kext as a DriverKit driver, rather than a simple port.
DriverKit drivers are permitted to be included in App Store apps.
I don't know if a DriverKit based HID driver will solve your specific power management issue.
If you go with a DriverKit solution, this will only work on 10.15+.
I suspect that AntiSleep may also be creating a virtual keyboard and mouse.
I haven't looked at AntiSleep, but I do know that in addition to writing an outright HID driver, it's possible to generate HID events using user space APIs such as IOHIDPostEvent(). I don't know if those are allowed on the App Store, but as far as I'm aware, IOKitLib is generally fine.
It's possible you might be able to implement your virtual input device using those.

How to test a VB program which will run on a network

I am a self-taught programmer and have only delved into new areas of programming as the need arises. I have never done any network programming, everything I have written has been for a single computer. I have written a program for an old board game and it runs great. But, now I want to try to write it to run for multiple players across a local network. I have an idea of what has happen in terms of constantly checking a specified folder/file for changes. But... how do you test this without actually building/compiling the program and installing it on another computer every time you make any changes? I have tried to search various forms of what I have as the title here, but all that comes up is about testing network connections, or socket programming (would this be easier/needed) or systemfilewatcher (which may be an option too if it will run on Windows 7 and 10... but, I find nothing about testing programs to actually access the network and simulating 2 copies of the program running. Any suggestions, links, etc. would be greatly appreciated.
I think you will be disappointed in the performance of a file-based network game unless reaction or refresh time is of little consequence for your "board" game. You may also need to work out potential concurrency issues (ie, someone updating a file you've just read). If you have any desire to do other games in the future you should be using sockets (most likely UDP unless you have a good reason not to) to create a client server system.
As to your question, yes, you should be able to test it. You just need to run both a compiled exe and the source in VS debug mode, accessing the same folder on your drive. If you go with the socket-based option, you would use your PC's loopback address 127.0.0.1 (sometimes known as localhost), but the 2 different parts will need to communicate on different ports.

How can I run an .exe on a server, but show output and interact client-side?

I want to run an .exe (Halo to be specific) on a server and then be able to view and interact with it through a browser, similar to a remote desktop. Is this even possible? I want to do this because we have nothing left to do in the last few days of school, and we wanted to play a Halo LAN, but are not allowed to install anything on the computer or run anything off of a flash drive, thus this was an idea we came up with.
Well, in principle it would be possible (though performance would probably be a problem), but in order to do this, you'd need at least some kind of viewer on the client. This in turn would need to be installed :-).
You could try to set up a VNC server, then use the TightVNC java viewer. That would work if the school's computers have Java set up. Still, I don't believe you'd get usable performance (VNC typically gives you 1 FPS at best).
Your best option is to either play browser games, or just do something else with your time. You might even try studying something interesting :-).
There is a way, and it's called CGI, but you won't be running Halo with it anytime soon.

Api to turn on your computer

I'm Making a small on-line clock (both for fun and to learn a bit more of php and javascript) started it because i actualy need an alarm clock and this would be easier than buying one (don't ask)
Now i wanted to know one thing, i know it's impossible to turn on/off you're computer from a browser, but a friend asked me if i could do him a small addon/program that would fetch the alarm time he added there, and would turn his computer on so it would let if wake up
I know turning on must be pretty much impossible, but turning on from sleep/hibernate maybe?
Anyone knows any api to do this? Windows or mac, or cross platform.
Just for curiosity the alarm clock is here http://www.my-clock.net
Edit:
On the wiki page, wake-on-lan says it requires to turn the bios power to the network-board, is there any way arround this? Or are todays computers already ready for this kind of protocol?
There could be two solutions:
Use Wake-on-LAN as was suggested. But you must have another machine up on that LAN, it doesn't work over the Internet itself. So it goes like You -> [Internet] -> Waker -> Your friend.
You can set his RTC wakeup alarm over the Internet while his machine is still up and running. Then his computer will wake at the specified time.
Both would work even if the computer is completely powered-off.
Once a OS goes in hibernate/sleep the only way to bring it up is through some kind of kernel level hardware driver event. for example pressing power button or opening the lid of the system etc.
IMO it would be bit complex to model the functionality within an application, as application is dependent on OS level services, that are not available in sleep/hibernate mode.
I don't know a lot about how it works, but it sounds like you need Wake-on-LAN
Wake on LAN (WOL, sometimes WoL) is an Ethernet computer networking standard that allows a computer to be turned on or woken up remotely by a network message.
Your best bet may be Wake-on-LAN
As people have pointed out, Wake-On-Lan is one possibility. But there's another one that might suit your need. Most BIOS'es today already provide an option to turn your computer on at a given time. If your goal is simply to turn your computer into an alarm clock, this should do the trick.