473,386 Members | 1,793 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Resume computer from stand-by through serial port

Tyler Wiebe
Okay, I'm wondering how I would go about waking my computer from stand-by mode from pushing a button that is connected to a serial port cts line. Anyone know how?

Currently, I have it so that if I let go of the button, it'll go into stand-by mode in 5 seconds, I need it so that when I push the button, it'll resume like when you push a button on the keyboard.

Expand|Select|Wrap|Line Numbers
  1.     public partial class Form1 : Form
  2.     {
  3.         public static Thread newThread = new Thread(new System.Threading.ThreadStart(_Activate));
  4.         public Form1()
  5.         {
  6.             InitializeComponent();
  7.             if (serialPort1.IsOpen)
  8.             {
  9.                 button1.Text = "Close";
  10.             }
  11.             else if (!serialPort1.IsOpen)
  12.             {
  13.                 button1.Text = "Open";
  14.             }
  15.         }
  16.  
  17.         public static void _Activate()
  18.         {
  19.             Thread.Sleep(5000);
  20.             Application.SetSuspendState(PowerState.Suspend, false, false);
  21.         }
  22.  
  23.         public void serialPort1_PinChanged(object sender, System.IO.Ports.SerialPinChangedEventArgs e)
  24.         {
  25.             if (!serialPort1.CtsHolding)
  26.             {
  27.                 if (!newThread.IsAlive)
  28.                 {
  29.                     try
  30.                     {
  31.                         newThread.Start();
  32.                         BackColor = Color.Green;
  33.                     }
  34.                     catch
  35.                     {
  36.                         newThread = new Thread(new System.Threading.ThreadStart(_Activate));
  37.                         newThread.Start();
  38.                     }
  39.                 }
  40.             }
  41.             else if (serialPort1.CtsHolding)
  42.             {
  43.                 if (newThread.IsAlive)
  44.                 {
  45.                     newThread.Abort();
  46.                 }
  47.             }
  48.         }
  49.  
  50.         private void button1_Click(object sender, EventArgs e)
  51.         {
  52.             if (!serialPort1.IsOpen)
  53.             {
  54.                 serialPort1.Open();
  55.                 button1.Text = "Close";
  56.             }
  57.             else if (serialPort1.IsOpen)
  58.             {
  59.                 serialPort1.Close();
  60.                 button1.Text = "Open";
  61.             }
  62.         }
  63.     }
  64.  
Jun 5 '11 #1
4 2621
Plater
7,872 Expert 4TB
I think you need to look at the power settings of the computer, and find the option that is something like "allow this device to wake the computer"
Jun 8 '11 #2
I checked and there is no option or power management tab for that device, it's a USB to Serial Port Adapter, and I checked all of the USB ports power management, and all there is, is a checked "Allow the computer to turn of this device to save power", and a darkened, non-checked "Allow this device to wake the computer".

And one last detail I forgot is that if I can get this working, I plan to install a sensor in my chair, so when I sit down, it'll wake up, and after 5 minutes of being of the chair, my computer will go in to stand-by mode.
Jun 11 '11 #3
Plater
7,872 Expert 4TB
Hmm if you dont have the option to wake it up, I don't think you can do it. PRetty sure no code runs while sleeping (except basic hardware io)
Jun 13 '11 #4
Okay thanks anyway, the best I could do was make a wait-able timer that would wake the computer up after a certain amount of time.
Jun 16 '11 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Ian DeRock | last post by:
I'm fairly new to XML. As I can see it, XML is a way to organize data like in a table in a RDB, or the RDB itself. I have used XML in application data, but did not design the actual XML. I...
3
by: Todd D. Levy | last post by:
What do I need to get (from Microsoft I assume) in order to distribute stand alone Access applications to people who do not (and will not) have Access installed on their systems? I have heard...
1
by: George W. Jackson | last post by:
I copied the code below and saved it as a .vbs file. Can anyone tell me why I would be getting an 800A0005 error while another XP Pro. and a 2000 machine can run it just fine? The error is "An...
3
by: Blaxer | last post by:
I am asking this question again in hopes that someone can answer it this time. Does anyone know if there is a way to have an event fire when a computer resumes / wakes up from sleep mode...
7
by: Michael | last post by:
Hi Everyone, I'm using VS 2005 now and would like to know if .Net has a replacement for the Resume Next clause. I would like to do something like the following: On Error Resume Next value =...
4
by: a8736d53 | last post by:
Is it possible to install PHP on a stand alone WinME computer, and have the .php files work exactly like they do on an Internet server?
2
by: jim-on-linux | last post by:
py help, The file below will run as a stand alone file. It works fine as it is. But, when I call it from another module it locks my computer, The off switch is the only salvation. This...
0
by: trusharn | last post by:
hi, I m Trushar. I wanted to install Ms-Sql 2000 with Windows XP Pro on a stand alone computer. It's not in network. so plz guide me what to do now..... thanx .....
1
by: =?Utf-8?B?RGViSA==?= | last post by:
Hello, I am not connecting to an office network anymore so I changed the "setting" to take off the network and use the computer as a stand alone. After rebooting, I cannot log on AT ALL!! "System...
0
by: Infiniti Languages | last post by:
Earn adequate income from home through online / offline jobs. Any well educated having good command over any two languages, can be housewives, retired, students and working persons. No special...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.