|
I am doing a school project where we have to build a device with a microcontroller inside that will have different tasks. The device will be sending and receiving info wirelessly to a PC and one of the objectives of the project is for the device to be able to shutdown the computer. I am not much of a programmer but i have other group members who are. What is an ordnance? Is this my only option? Is there any code involved?
|
|
|
|
|
Jerome Crooks wrote: What is an ordnance?
A weapon. Your question was vague and so you got a joke answer.
You can turn off a computer by running code, you could look at the mother board to see if there's a jumper you can wire up to, and connect to shut down. It's kind of a hardware question, not a programming one really. ( that is, if you want to turn off a computer via another device, and not in a program on the computer, then it becomes a hardware question )
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
Christian Graus wrote: you could look at the mother board to see if there's a jumper you can wire up to, and connect to shut down.
I've never seen a jumper to do this, some enthusiast mobos do have onboard power/reset switches that could be manually pressed/pressed by a hardware device.
Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots.
-- Robert Royall
|
|
|
|
|
Hi,
you could set up one function key to execute the DOS shutdown command, and build your own USB keyboard emulator that emits the right function key code when you want the shutdown to occur.
|
|
|
|
|
I found these examples[^] to cause many a sleepless night
You can bluntly take the power of the computer, but I guess that you are looking for a method to send a signal to the computer and to shut it down "the friendly way".
I are troll
|
|
|
|
|
I don't know about an external micro-controller, but you could do something like this:
uchar reset = 0;
do
{
reset = inportb(0x64);
if(reset & 1)
inportb(0x60);
} while (reset & 2)
outportb(0x64, 0xFE);
That'll pulse the keyboard reset line. It should be rather simple from there to translate it into assembly code and encode it into the micro-controller
|
|
|
|
|
I'm sure there's an API call to shut down the computer gracefully as if you clicked shut down yourself.
You could call that from C# code using PInvoke.
Interfacing a uC to a computer is reasonably easy via serial or parallel ports, marginally more difficult via USB - I've never tried a wireless port.
There's no reason why a uC can't talk to your C# app via one of these ports which in turn shuts the PC down.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
I am also an electronics and communication engg.
One thing you can do is create a small windows service which scans your serial port where microcontroller is connected. and whenever your controller sends some specific serial data, you can run a C# code to shut down your PC..
This might work.
|
|
|
|
|
And in that service you can execute a small line of code...
System.Diagnostics.Process.Start("Shutdown", "-s -t 01");
this will shut down the computer . ..
|
|
|
|
|
Almost every motherboard has a jumper you can use, it's where they plug in the wires for the power switch on the outside of the case. Almost all of them function the same way as well, short the circuit, and it starts the shut down/power up sequence.
You can also control the power from the power supply tap to the motherboard, many power supplies also have their own power switch (usually much higher voltage) and there is a way to do it through the PCI bus as well. Going further out, you could also cut power to the entire system from the power cord.
In the end it really depends on how 'micro' the controller really is and what voltages you're dealing with. A 110 volt switch is probably a bad idea for hooking up to a motherboard jumper, however you could simply kill the power to a battery backup and let the system shut itself down. In the 12 volt range you could use one of the power supplies used for car based computers. If your running off the USB line, then the motherboard power switch is probably your best bet.
As others have mentioned:
System.Diagnostics.Process.Start("Shutdown", "-s -t 10");
Will also turn the computer off.
The true man wants two things: danger and play. For that reason he wants woman, as the most dangerous plaything.
|
|
|
|
|
Hi guys, whats going on ?
I have a form called Form1, there's a button which I click and Form2 is opened, now I want to send a value from Form2 back to Form1
(I know how to do it from a form to a new form!)
thx
|
|
|
|
|
Use an event in Form2 that Form1 subscribes to. There's an example in my article here[^].
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
One of the best way to pass some value is by overloading the constructor.
For e.g if you want to pass an integer id or something like that from form1 to form2.
you need to do is make a small function on form2 like :
public Form2(int id)
{
InitializeComponent();
this.ID = id;
}
And while opening the form2 in form1 you need to do is
Form2 frm = new Form2(3); //3 can be replaced by any variable.
frm.showdialog();
or
frm.show();
|
|
|
|
|
See, Form 2 is already open through Form 1 !!!
Form2 F2 = new Form2();
SelectedGrammarID = Convert.ToInt32(SelectedRow.Cells["GrammarID"].Value);
this.Close();
I want to send the value "SelectedGrammarID" back to form 1!!!!
now I select a value in form 2 and click on a button, it closes the form and then I want to send the value to a Variable in Form 1 (I don't open the form again because it's already open !!!!)
Mr.K
|
|
|
|
|
Like I said before, use an event!
Add a new class IDEventArgs with this code
using System;
public class IDEventArgs : EventArgs
{
private int _ID;
public IDEventArgs(int id)
{
_ID = id;
}
public int ID
{
get { return _ID; }
}
} Add this to Form2
public event EventHandler<IDEventArgs> GrammarIDSelected;
private void CompleteFormProcessing()
{
OnGrammarIDSelected(new IDEventArgs(
Convert.ToInt32(SelectedRow.Cells["GrammarID"].Value)));
Close();
}
protected virtual void OnGrammarIDSelected(IDEventArgs e)
{
EventHandler<IDEventArgs> eh = GrammarIDSelected;
if (eh != null)
eh(this, e);
} Call CompleteFormProcessing from wherever you need it.
In Form1 add these.
Form2 F2 = new Form2();
F2.GrammarIDSelected += new EventHandler<IDEventArgs>(F2_GrammarIDSelected);
F2.Show();
void F2_GrammarIDSelected(object sender, IDEventArgs e)
{
}
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
I'm just curious, is there a way to build an executable that will run on a computer that doesn't have the .NET framework installed?
i know that we can package our exe with dotnet framework which will install framework before installation.
but is their any solution without installing .
something like when we create exe thru vc++ compiler.
“You will never be a leader unless you first learn to follow and be led.”
–Tiorio
"Coming together is a beginning, staying together is progress, and working together is success." Henry Ford
|
|
|
|
|
Easy, don't use a .NET language.
There are some cheats to package the entire framework with the program and then Not install it but do some other magic, but IMO that's even worse then telling users to download/install the .NET framework (would they like a 100MB+ program that needs only be 1 - 5MB? I don't think so)
Or maybe Mono's "full static compilation" will work also? I don't know.
Maybe cr88192's project will do this..? Not too much is known about it..
|
|
|
|
|
There are products out there that will do something like this, but they all cost big money. There are no free ones that do this.
|
|
|
|
|
As Dave said, products do exist but they are expensive, google for xenocode postbuild and you will have one such example.
|
|
|
|
|
Xenocode[^] will create an executable that doesn't need the framework to run. Your apps still delivered in MSIL and running .net code though, the needed parts of the framework and CSC.exe are embedded with your original app into the file you deliver. This results in a large 20-30mb executable even for small apps.
The RemoteSoft[^] linker and mini-deployment tool will convert your app into native code, so that there's no MSIL in your delivered files. The current version doesn't embed any of the native dlls from the framework that you use into the executable, so you have a series of folders with 20-30megs of them (possibly more). If you use XML serialization the automatically created IO classes will still be generated as managed code. I've played with this (and may be getting a copy for work); my big concern at the moment is that the author has been very poor about responding to email queries. If everything works more or less out of the box (it appears to at present) it shouldn't be an issue, but I'm worried about what if any major problems turn up.
VMware offers a similar product but it's ~$5k vs ~1k for the other two and AFAIK functions at the same level as xenocode.
Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots.
-- Robert Royall
|
|
|
|
|
I am astounded that people ask this still. Yes, there's a /NOFRAMEWORK switch on the compiler, we just don't use it b/c we like to make people download the framework.
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
In my case DLing the framework has had nothing to do with it. We made a app for X several years ago. X wants us to make a version of it for Y, but is freaking over the reverse engineering risks. This is a CheaperThanAC++Port option for us. (NTM my experiance with MFC and C++ more generally is limited to messing around as a student years ago so there'd be a major learning curve involved).
Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots.
-- Robert Royall
|
|
|
|
|
So , if i compile with /NOFRAMEWORK in my machine and run that exe in another machine that doesn't have framework, will that exe run.
“You will never be a leader unless you first learn to follow and be led.”
–Tiorio
"Coming together is a beginning, staying together is progress, and working together is success." Henry Ford
|
|
|
|
|
Congratulations!
Your response has reached position 26 in a Google search for NOFRAMEWORK. A sterling effort.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
This /NOFRAMEWORK option is not available in csc.exe, i don't know y u have given me this suggestion.
“You will never be a leader unless you first learn to follow and be led.”
–Tiorio
"Coming together is a beginning, staying together is progress, and working together is success." Henry Ford
|
|
|
|