LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Headless Operating System

Has anyone any experience of using embedded NT as a operating system for a headless PXI based Motion control system and its resilience to power shut downs and restart.
We are mandated to using Labwindows CVI so the use of a RT PXI controller is out at present.
0 Kudos
Message 1 of 7
(4,311 Views)
While I don't know the specifics on Embedded NT, NT Workstation 4.0 can be made to run headless right out of the box with some registry tweaks.

The tweaks required are described in the O'Reilly book "Managing the Windows NT Registry" by Paul Robichaux. You essentially enable auto-logon after boot, and you defeat pop-ups during boot (when headless, if a popup were to occur during boot, the system would hang forever - you wouldn't know of it and you wouldn't be able to respond anyway). You can then have the system run your app automatically on startup by making it either a service or putting it in the "Startup" folder. If needed, you can use a utility called "Winkey" I think it was to spoof NT into thinking a keyboard and mouse are connected. Winkey was found
in the accessibility folder on the NT install CD I believe. I had good luck using this technique, works like a champ, no CRT, no keyboard, no mouse hooked up at all.
0 Kudos
Message 2 of 7
(4,310 Views)
While I don't know the specifics on Embedded NT, NT Workstation 4.0 can be made to run headless right out of the box with some registry tweaks.

The tweaks required are described in the O'Reilly book "Managing the Windows NT Registry" by Paul Robichaux. You essentially enable auto-logon after boot, and you defeat pop-ups during boot (when headless, if an error popup were to occur during boot, the system would hang forever - you wouldn't know of it and you wouldn't be able to respond anyway). You can then have the system run your app automatically on startup by putting it in the "Startup" folder. You can also cause an app to load and run at startup by naming it in the registry. If needed, you can use a utility called "Winkey" or "MouseKey" I think it was
to spoof NT into thinking a keyboard and mouse are connected. Winkey was found in the accessibility folder on the NT install CD I believe. I had good luck using this technique, works like a champ, no CRT, no keyboard, no mouse hooked up at all. My app fires up on bootup, and will restart in the event of power failure. I also hooked up some code to do a programmatic shutdown of my app and NT on power fail (when using an UPS of course).

Windows NT resource kit has a tool for turning your app into a service, whereby it will start up automatically WITHOUT a logon (no need to configure NT for auto-logon).

Win 2k has a built-in tool that makes it easy to configure an app to run like a service.

If you're interested in any of this I can provide more detail.
0 Kudos
Message 3 of 7
(4,310 Views)
I'm interested in your power failure/shutdown implementation. How big a UPS did you use?

It sounds like we may be able to use NT 4.0 instead of NT embedded if we use your tweaks.

Mike...
0 Kudos
Message 4 of 7
(4,310 Views)
Hi Mike-

We used an APC 600W UPS with a serial link to the PC. We went through a BIG hassle with APC to get them to disclose their communications API to the UPS - normally they want you to use their canned software to implement shutdown in the event of power fail. As it was, we simply monitor the serial port for any incoming character, and on receipt of any incoming character from the UPS, we start a shutdown.

Programmatic shutdown of apps and NT itself are described in the Win32 SDK that comes with the CVI Full Scale Development System (FDS).

We sized the UPS to provide power to the PC as well as a couple of instruments in the system. Our goal was to save off data to hard disk and then do an orderly shutdown.

You have to enabl
e shutdown privledges in NT:

// Get a pseudo-handle to this process.

hProcess = GetCurrentProcess ();

// Enable NT shutdown privilege for this process.

OpenProcessToken (hProcess, TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken);
LookupPrivilegeValue (NULL, SE_SHUTDOWN_NAME, &tkp.Privileges[0].Luid);
tkp.PrivilegeCount = 1;
tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
AdjustTokenPrivileges (hToken, FALSE, &tkp, 0, (PTOKEN_PRIVILEGES) NULL, 0);

Then to do a shutdown of all apps (forced) and then shut down NT:

InitiateSystemShutdown (NULL, // address of name of computer to shut down
NULL, // address of message to display in dialog box
0, // time to display dialog box
TRUE, // force applications with unsaved changes flag
FALSE // reboot flag.
);

You can
also install a main window callback in your app to recieve the Win32 "EVENT_END_TASK" message from NT sent to all apps when the system is shutting down.

Bob Hayes
0 Kudos
Message 5 of 7
(4,310 Views)
Hi again Mike-

Some more thoughts---

There are some issues with the scenario I depicted.

1. The APC UPS can (and I think usually will) send a message over the serial port that it's switched onto battery power. It will send another message when it's down to about 5 minutes of battery power left. We interpreted ANY character to mean imminent power failure and we would shut down the app and NT.

2. In the case that power is restored before the battery power is exhausted, the PC will sit there powered on but "dead" with NT shut down. Unless the power is cycled or the PC is reset, NT won't automatically restart. We solved this by using an AC power outlet to the system with remote on/off capability. If NT shut down, we would command a power off / power on cycle when power was restored to guarantee a system reboot.

Don't know of a really good solution to this: you can never be certain that power will actually fail once the UPS signals that it's on battery. If you've shut down NT, you can't get it going again in any way that I know of save for reset/power cycle/keyboard input. I've seen implementations where they remote the reset button on the PC for this very reason 😉

If you sized the UPS to have enough power to run the PC in the event of any likely power failure, you could maybe code it to only really shut down NT when the battery power was really about to fail. Good luck on getting APC to tell you what the exact messages are from the UPS 😉

You might be able to get away with shutting down your app but leaving NT running and have a single process running like a "watchdog" that will wait some amount of time and then restart NT. If power DOES fail, then the process of course dies and NT retarts on power re-application. If power DOESN'T fail, then the watchdog process will succeed in restarting NT. NTFS is robust - your guaranteed that the file system will be left in an intact state in the event of an arbitrary shutdown (power slammed off). We used to walk up and arbitrarily slap power off on the system to demo that the file system stayed intact.

Bob Hayes
0 Kudos
Message 6 of 7
(4,308 Views)
Thanks for the info Bob
It certainly re-enforces my initial thoughts.
I think power shut down will be positive as the power to my system will be remotely isolated from the master console or will be removed upon operation of the emergency stop button.

Thanks again for all the info I will keep you informed of the progress over the coming months.

Mike...
0 Kudos
Message 7 of 7
(4,308 Views)