
ThermoProtect V1.34

Author               : David Wei
E-Mail Address       : davidwei@cybermail.net
Web Site             : http://www.pcenduser.com/ThermoProtect

Program Function     : Monitor system temperature, fan speed, and 
                       voltage.

Software Requirements: OS/2 Warp 3.0 or OS/2 Warp 4.0 (runs fine on 
                       any language version).

Hardware Requirements: A system that can run OS/2 and that comes with 
                       a Winbond W83781D, Winbond W83782D, National
                       Semiconductor LM78/79, or compatible hardware-
                       monitoring chip.



New Version Highlight :
=======================

*Because the ThermoProtect's heating code does not work to my satisfaction, so I
 started by putting the heating code in a thread of its own.  Now ThermoProtect's
 main program will start and stop the heating thread on command, no longer would a
 timed loop be needed in for heating purposes, ThermoProtect will heat the CPU to
 just over the prescribed temperature and stop right there.  Because now the
 heating code is in a different thread, it is a lot easier to show visual
 indication that the heating thread is activated. (Yellow text and red background
 in text mode, or "H" showing up in named pipe mode) Not only this, but I have set
 the heating thread to Idle Priority, Delta 1.  This makes the system work smooth
 as silk even when the heating function is activated, unlike what ThermoProtect
 V1.33 does. (Well, it was a quick hack. :) ) I set the Delta to 1 because most
 CPU "sucker" program (RC5/DES, SETI@Home, prime number finder and whatever else)
 usually have their delta set to 0, and if anything goes wrong with them, I would
 want my heating thread to be able to outclass them in the priority ranking, so
 that it can work properly.

 Yipee! This is my first multi-threaded (or should I say, DUAL THREADED?) program,
 and it is also my first program that actually NEEDS to have more than one thread.
 :)



Introduction:
=============

I wrote ThermoProtect because at the time most environmental-monitoring
software did not support OS/2, and what OS/2 environmental-monitoring
software there was did not properly support the Winbond W83781D
monitoring chip.

I use an EPoX MPV3G-M ATX (Just upgraded! :) ) motherboard in my machine,
which has an integral Winbond W83781D monitoring chip.  One very strange
thing about that motherboard is the monitor-chip wiring, which is
connected in such way that only the second and third temperature inputs
are used.  Thus NO monitoring software supporting the National
Semiconductor LM78 can properly display the temperature.  It was that
shortcoming that started me on the path to ThermoProtect.



Features:
=========

* Supports all monitoring function of the following System Health
  Monitoring chips:

       Winbond 83781D
       Winbond 83782D
       National Semiconductor LM78
       National Semiconductor LM79
       And other compatible chip/chipsets.

* Supports both native Text Mode display and GUI interface.
  GUI interface is done by SysBar/2's Pipe Monitor.

* Capable of output to file in 100% standard text file format.

* Capable of output to named pipe.

* A ThermoAlarm that generates both audible and visual warnings when
  fans or temperatures are outside their specified safety limits. 
  (Try it by deliberately setting a limit value to trip the alarm, so
  you get familiar with the warning signals :) )

* Temperature Watch function now will allow ThermoProtect the ability to
  keep your CPU above a certain temperature limit that you have set.
  This is designed for Peltier users who needs to keep the CPU above a
  certain temperature to prevent condensation from froming on the CPU.
  Since V1.34, this feature will work a LOT smoother than before.

* ALL user inputs for the program are obtained from text configuration file,
  making ThermoProtect suitable for automatic spawning. (In the start up
  folder, for example... :) ) And it is very easy to do for remote
  configuration, so long as you got Telnet and/or FTP. :)

* Ultra-low system resource reuqirement, run it on a text mode only
  low budget server and you will not see much in the way of difference
  in performance.

* Dual-Language support, with display routines designed for easy
  addition of more languages.

* Automatic or manual Code-Page switching: ThermoProtect will detect 
  which Code Page your system is using and display accordingly, or you
  can use the configuration file to force a specific Code Page.
  (At present, only Code Pages 850 (U.S.) and 950 (Taiwan) are 
  supported; for any other detected Code Page, ThermProtect will 
  default to Code Page 850.)



Installation:
=============

Text Mode Only:

Simply unzip ThermoProtect to any directory you like, and that's all you
need to do to install ThermoProtect! No reboots, no DLLs and no CONFIG.SYS
update needed!


GUI/Text:

With GUI mode operation, ThermoProtect relies on SysBar/2's Pipe Monitor,
which requires you to install an extra DLL, please place it in your \OS2\DLL
directory. Else, you can simply add another entry in your config.sys' LIBPATH
statement to point at the proper directory and reboot to update the setting.



Quick Start:
============

Text Mode:

ThermoProtect couldn't be simpler to use:  just run ENVIRO.EXE.  If you
are using a Code Page other than 850 or 950 (the currently supported
ones), don't worry--ThermoProtect will default to the US-English (850)
Code Page for its display, which should be satisfactory for most users.

Please note that when you use ThermoProtect with the standard Enviro.CFG,
it will cause the ThermoProtect to run in the standard "spectator" mode.

As for the user interface, there really isn't one.  When you want to
exit ThermoProtect, just press *any* key while the program is in the
foreground, and the program will quit.

While running, ThermoProtect updates its information every 1.6 second,
but uses a very small amount of system resources: I could not see any
impact at all on my CPU-monitoring program from running it.

GUI Mode:

First, edit the Enviro.CFG and place the desired warning value in there,
and then run "SB2_PIPE.EXE" and then run "Enviro.EXE". You will see all
the monitored value popping up on the Pipe Monitor. Point your mouse
cursor at the desired value, and the a simple description of the value
will show up in a bubble window. Currently the ThermoAlarm is disabled
in this mode.



Configuring ThermoProtect:
==========================

ThermoProtect's setup utility EnvSetup.EXE, will edit the Enviro.cfg
file for you, easily and quickly. There's NO learning curve involved!
Just up, down, Enter, ESC, F10 and file name or numerical input!

To move the light-bar
Up/Down keys

To exit the current menu (or moving the light bar to "EXIT")
ESC

To move the light bar to Save and Exit at the main menu
F-10

To activate the selection that the light-bar is on
Enter


Menu choices:

CodePage Selection Setup:
This option allow you to tell ThermoProtect which codepage it should
use, or should it detect the code page automatically.
Default: Automatic.

Chipset Selection Setup:
This option allows you to tell ThermoProtect which chipset support is
should use on your computer, or should it detect the chipset
automatically. This option should be left untouched unless you believe 
hat ThermoProtect is incorrectly detecting your chip.
Default: Automatic.

Output Option Setup:
You can use this option to have ThermoProtect output the data to screen,
file or named pipe. You can also tell ThermoProtect the name of the file
it should output to. Output to screen will present you with the good old
text mode display. When output to file, it will create a standard text
file containing all the data that originally would be output to the
screen. And output to named pipe will enable other program like SysBar/2's
PipeMonitor to read ThermoProtect's output.
Default: Screen.

Setup ThermoAlarm for Fans:
You can use this option to tell ThermoAlarm function to watch the Fans'
RPM reading, when it falls below the specified value, ThermoAlarm will
warn you with audiable sound. Warning, this option will be disabled
if you use file output.
Default: Disable all.

Next Page/Previous Page:
Well, for switching between configuration choices.

Setup ThermoAlarm for Temperatures:
You can use this option to tell ThermoAlarm function to watch the thermal
probes' temperature reading, when it rise above the specified value,
ThermoAlarm will warn you with audiable sound. Warning, this option will
be disabled if you use file output.  Also you can setup the temperature
modifier values here. Temperature modifier is an value that will be added
to the actual readout before it is sent to the output destination. Use
this option, you can match the temperature modifier in some motherboard's
BIOS reading. (They add the modifier because the thermal probe is not in
contact with the CPU, and they want to get an better approximation of the
actual CPU temperature)
Default: Disable all.

Setup Low Temperature Watch:
You can use this option to tell ThermoProtect not to allow the CPU to fall
to and below this temperature. This feature is created because I had a
Peltier/Water Cooling disaster that I have here. (The SETI@Home ran out of
things to do, and the Peltier/Water Cooling managed to lower the CPU's
temperature below freezing point. When SETI@Home finally got something to do, it
melted the ice formed on the CPU, which then caused a short... Good thing that
it does not appear to have done real damage.) I decided that I need to have a small
program that can create CPU load to heat up the CPU to prevent the CPU going below
a pre-defined temperature limit. Thus Temperature Watch function was created.
It runs a small timed loop that does intensive float point and integer calculation,
which will heat up the CPU quite nicely.
Default: Disable all.

Save And Exit:
Heck, I think I don't need to explain that. :)

Discard Change And Exit:
Well... Read the above. :)

That's about all there is to EnvSetup!


It is als quite easy to configure ThermoProtect manually with an text
editor, I don't think I really need to explain it, just open Enviro.CFG
(after you first ran Enviro.exe or EnvSetup.exe, either will create one)
and you will understand how to configure it almost instantly. :)

Warning, if you ENABLE output to File, it WILL DISABLE ThermoAlarm
AUTOMATICALLY!!! WARNING!!!

Named Pipe output now fully supports ThermoAlarm.



Using Pipe Montior with ThermoProtect:
======================================

ThermoProtect comes with a copy of pre-configured pipe monitor that is
ready to use right out of the box. It will show all the data that the
text mode display would, but in a more elegent manner.

Themperature display of the Fahrenheit scale is disabled in the Pipe
Monitor, but they can be enabled at any one time. Simply RMB Pipe
Monitor and choose Properties, Cells and then edit the cells with
the name "Temp#1F", "Temp#2F" and "Temp#3F" and select "enable cell"
in each cell's property setup to enable the display.

For more detail, please refer to Pipe Monitor's docs...

Named Pipe output now fully supports ThermoAlarm. Again, anything
monitored by the ThermoAlarm will show an "*" marking. Since I can't
send command to highlight the item that's triggering ThermoAlarm,
instead, "!" will show up indicating troble in that input.



Using Named Pipes:
==================

Yes, YOU can use Named Pipes' output in your program, it is simple,
very simple.  Your program will act as a server and the ThermoProtect
will act as a client, and you simply kept reading the stuff coming in
from ThermoProtect. :)

(Most code examples and tips on this are done by Dmitry I. Platonoff.)

Create the Named Pipe in the following manner...

 DosCreateNPipe( pszPipeName, &hPipeHandle ,
   NP_ACCESS_INBOUND, NP_NOWAIT | NP_TYPE_BYTE | NP_READMODE_BYTE | 1,
   iPipeBufSize, iPipeBufSize, 0L );

That means that you are only going to READ data sent to the program by
a ThermoProtect, and the NOWAIT flag which allows the program to not to
wait for pipe events. (Pipe Monitor have a semaphore attached to a pipe
and a second thread which wakes up to this semaphore when any event with
my pipes happens).

After the DosCreateNPipe command, you will want to connect the pipe, so
that ThermoProtect can "pipe" the data over. Simply do the following:

 DosConnectNPipe (&hPipeHandle);

And that's basically it, for more information on how to use named pipes,
check out IBM's on-line library at "http://www.ibmlink.ibm.com/cgi-bin/master?xh=Jj$R$BJ*TxSis10USenGn332&request=ibmmanuals&parms=bej6c1b01&xhi=usa%2emain".

The following is a list of named pipes used by ThermoProtect.

#1 Fan #1 Speed, in RPM, pipe name: \pipe\tp-fan1
#2 Fan #2 Speed, in RPM, pipe name: \pipe\tp-fan2
#3 Fan #3 Speed, in RPM, pipe name: \pipe\tp-fan3
#4 Temperature Probe #1, in Celsius, pipe name: \pipe\tp-temp1
#5 Temperature Probe #1, in Fahrenheit, pipe name: \pipe\tp-temp1F
#6 Temperature Probe #2, in Celsius, pipe name: \pipe\tp-temp2
#7 Temperature Probe #2, in Fahrenheit, pipe name: \pipe\tp-temp2F
#8 Temperature Probe #3, in Celsius, pipe name: \pipe\tp-temp3
#9 Temperature Probe #3, in Fahrenheit, pipe name: \pipe\tp-temp3F
#10 CPU Core Voltage A, in Volts, pipe name: \pipe\tp-VcoreA
#11 CPU Core Voltage B, in Volts, pipe name: \pipe\tp-VcoreB
#12 +3.3 Volt monitoring, in Volts, pipe name: \pipe\tp-3.3V
#13 +5.0 Volt monitoring, in volts, pipe name: \pipe\tp-5V
#14 -5.0 Volt monitoring, in volts, pipe name: \pipe\tp-m5V
#15 +12.0 Volt monitoring, in volts, pipe name: \pipe\tp-12V
#16 -12.0 Volt monitoring, in volts, pipe name: \pipe\tp-m12V
#17 CMOS Battery monitoring, in volts, pipe name: \pipe\tp-CMOS
#18 +5V Stand By monitoring, in volts, pipe name: \pipe\tp-VSB
#19 Case Intrusion monitoring, False/True, pipe name: \pipe\tp-case


Named Pipe output now fully supports ThermoAlarm. Again, anything
monitored by the ThermoAlarm will show an "*" marking. Since I can't
send command to highlight the item that's triggering ThermoAlarm,
instead, "!" will show up indicating troble in that input.


Have fun! :)



Tips & Tricks:
==============

I have claimed that ThermoProtect can use so little resource that the
CPU monitor won't notice it. Not even RC5DES's key cracking report will
show it (when you inculde the uncertainty of the value)!  How do I do
that?

Well, it's easy.  First, run ThermoProtect for a while, keeping an eye
on the normal spectrum of temperatures and fan speeds that it shows
(do be sure that your computer is running normally--that is, at safe
temperatures and fan speeds--when you do this).  After you have a good
idea of both the normal averages AND the normal ranges of variation
from those averages for all reported temperatures and fan speeds, you
can select limits to specify for each.  When selecting limits, choose
values that are not likely (from what you saw during your trial runs)
to occcur in normal operation BUT that are not so far from those norms
that your computer would melt down (figuratively or literally) before
ThermoProtect would start sounding alarms.  Now edit the enviro.cfg
and put the limits in, then yourestart ThermoProtect. Minimize the
window in which ThermoProtect is running.  Because OS/2 now does not
need to use any resources showing an actual text window, it will save
a *LOT* of resources (especially on computers with slower graphic cards).

Note: Using ThermoProtect in named pipe mode should also comsume little
resource, as both Pipe Monitor and ThermoProtect are designed to use as
little resource as possible! :)

For automatic execution on every boot, create a program object in the
start-up folder, and simply point it toward the enviro.exe. And go to
the session setup and select it as an OS/2 Windowed Session and
Minimize on start up. That's what I did on my system, works like a
charm!



Data Displayed:
===============

#1  ThermoAlarm (Indicating if any of the ThermoAlarm is active or not)
#2  Fan #1 RPM
#3  Fan #2 RPM
#4  Fan #3 RPM (or, for dual-CPU machines, 2nd Power Fan)
#5  1st Temperature Probe
#6  2nd Temperature Probe (N/A on LM78 systems)
#7  3rd Temperature Probe (N/A on LM78 systems)
#8  1st CPU Core Voltage
#9  2nd CPU Core Voltage (for dual CPUs; on a single-CPU machine, this
    value usually will be the same as the 1st CPU Core Voltage reading)
#10 3.3V 5V 12V -5V and -12V
#11 CMOS Battery voltage
#12 5V Stand By Voltage.
#13 Chassis Introusion detection.


PLEASE NOTE!  The precision of the voltage-reading displays is greater
than the actual accuracy of those readings.  That high-precision
presentation allows small changes in voltage to be noticeable; that
is, even when the absolute value of the readings is not so exact as
the display, changes in the display correctly reflect changes in the
voltages, allowing you to spot potential trouble (sagging voltage
levels) at a very early stage.  Note that most monitoring chips'
readings are, by spec, plus or minus about 1%, so assume changes of
that magnitude to be "noise" in the readings; greater changes very
likely have significance and should be addressed by you in some way.



Wish List:
==========

*ATX Shutdown for system-wide failure when no manual shutdown occurs 
 within a safe time period.

*LM75 and LM80 style support. (those use the I2C/SMBus which makes
 the information a little harder to get at than it normally would 
 be since I'm not sure which port it's located at--but after a
 healthy/unhealthy dose of Intel Data Sheet, I should know.) :)



Acknowledgements:
=================

My thanks to all of these people: (In chronological order)

The Virtual Pascal/2 programming team and fPrint, for creating a
compiler of my favorite computer language on my favourite OS.

Christoph Bratschi and Bjrn Mork provided the program code from which
I learned hardware access in Virtual Pascal.  Without their work, this
program would have taken a whole lot longer to create.

Kevin Wu at EPoX, who provided me tips on how to set the Bank-Select
register properly (the Winbond datasheet doesn't express it properly)
and with whose help the Bank-Select bug was fixed in only a few
minutes.  Without his tip, I'd never have been able to program
ThermoProtect to read the two extra temperature inputs of the W83781D
chip.

Klaus Staedtler (stadt@ibm.net) for making a cute icon for my program,
and for providing a PROFESSIONAL looking icon for Version 1.09 and on.

Eric Walker (ewalker@highboskage.com) for making my English document
vastly more pleasent to read. :) And less confusing too... :) And
thanks to him that now my On-Line help is vastly improved from the
original.  Eric had later re-checked and re-written the ENTIRE DOC
AGAIN!!! THANKS, THANKS, THANKS! (Hell, reading my document could
be considered an achivement in itself. :) )

Amigo Chan (amigoccs@tpts4.seed.net.tw) for making my Chinese document
vastly more readable.

Konzmann@swol.de for finding that detection bug that shows up on some
motherboards (some Asus boards does this, but it should not be limited
to Asus only).

Adam P. Roycraft (adampr@ibm.net) for fine tuning this document to make
it even better! :)

Dmitry I. Platonoff (DPlatonoff@descartes.com) for helping me on named
pipes, not to mention allowing me to bundle a copy of Pipe Montior so
that ThermoProtect can actually have a GUI!!! :)

Bob Babcock (wssddc@gis.net) for helping me to find a fix for LM79's
non-update problem. Many thanks.


Okay, that's all for my primitive doc file; have fun with my program,
and PLEASE e-mail your comments to me.  I'm:

   David Wei
   davidwei@cybermail.net
   postmaster@pcenduser.com

[end]
