Serial patch for POSE 3.0a2
- From: Eskil Heyn Olsen <deity dbc dk>
- To: gnome pilot list <gnome-pilot-list gnome org>, pilot-unix hcirisc cs binghamton edu
- Subject: Serial patch for POSE 3.0a2
- Date: Mon, 15 Nov 1999 16:50:40 +0100 (CET)
Oy...
Either there is some unix pipes I don't know about, or pose really works
best with a nullmodem blocking both my serial ports (my laptop only has
one). Anyways, POSE's opening/closing of the serial port really annoyned
me and gnome-pilots gpilotd, and its cpu intensive reader/writer threads
simply annoyed me.
Attached you'll find a patch for POSE 3.0a2, which makes POSE keep the
serial port open at all time and decrease cpu load.
The modifications:
Platform class now has a SerialThreads(Bool).
In SrcShared, I've removed all calls to CloseSerialPort, replaced them
with Platform::SerialThreads(false).
Document.cc's hotsync calls Platform::SerialThreads(true),
emulatorStart/Stop calls Open/CloseSerialPort.
The SerialThreads(on/off) prevents POSE from eating cputime all the
time, and the threads themselves (CommWrite and CommRead) are now less
cpu intensive, but as fast (or slow) as before.
So if you're annoyed by POSE's behaviour, please patch, test and comment.
Also I was quite puzzled wrt. their object usage. They define a class
Platform with only static members, and in a file Platform_Unix.cpp fill in
the methods. Variables for the specific class still have to tbe declared
global, since they dont inherit from Platform. Que ?
/dev/eskil
---
diff -ru -x BuildUnix Emulator_Src_3.0a2patched/SrcShared/Bank_MC68328.cpp Emulator_Src_3.0a2/SrcShared/Bank_MC68328.cpp
--- Emulator_Src_3.0a2patched/SrcShared/Bank_MC68328.cpp Thu Nov 11 21:57:18 1999
+++ Emulator_Src_3.0a2/SrcShared/Bank_MC68328.cpp Fri Nov 5 12:28:07 1999
@@ -416,7 +416,7 @@
gLastTmr2Status = 0;
gPortDEdge = 0;
- Platform::SerialThreads (false);
+ Platform::CloseSerialPort ();
}
@@ -2475,7 +2475,7 @@
}
else if (!isOn && wasOn)
{
- Platform::SerialThreads (false);
+ Platform::CloseSerialPort ();
}
}
diff -ru -x BuildUnix Emulator_Src_3.0a2patched/SrcShared/Bank_MC68EZ328.cpp Emulator_Src_3.0a2/SrcShared/Bank_MC68EZ328.cpp
--- Emulator_Src_3.0a2patched/SrcShared/Bank_MC68EZ328.cpp Thu Nov 11 21:57:01 1999
+++ Emulator_Src_3.0a2/SrcShared/Bank_MC68EZ328.cpp Fri Nov 5 12:28:07 1999
@@ -384,7 +384,7 @@
gLastTmr1Status = 0;
gPortDEdge = 0;
- Platform::SerialThreads (false);
+ Platform::CloseSerialPort ();
}
@@ -2471,7 +2471,7 @@
}
else if (!isOn && wasOn)
{
- Platform::SerialThreads (false);
+ Platform::CloseSerialPort ();
}
// Clear the interrupt bits that are having a 1 written to them.
diff -ru -x BuildUnix Emulator_Src_3.0a2patched/SrcShared/Platform.h Emulator_Src_3.0a2/SrcShared/Platform.h
--- Emulator_Src_3.0a2patched/SrcShared/Platform.h Thu Nov 11 21:57:43 1999
+++ Emulator_Src_3.0a2/SrcShared/Platform.h Fri Nov 5 12:28:08 1999
@@ -134,7 +134,6 @@
// Serial-related functions
static ErrCode OpenSerialPort (void);
- static ErrCode SerialThreads (Bool);
static ErrCode SetSerialPortSettings (UART::Parity parity,
int stopBits,
int dataBits,
diff -ru -x BuildUnix Emulator_Src_3.0a2patched/SrcUnix/Document.cpp Emulator_Src_3.0a2/SrcUnix/Document.cpp
--- Emulator_Src_3.0a2patched/SrcUnix/Document.cpp Thu Nov 11 22:02:23 1999
+++ Emulator_Src_3.0a2/SrcUnix/Document.cpp Fri Nov 5 12:28:09 1999
@@ -113,7 +113,6 @@
void Document::emulatorStart (void)
{
- Platform::OpenSerialPort();
_cpu->StartThread ();
propertyChanged (cpuStatusChanged);
}
@@ -124,7 +123,6 @@
void Document::emulatorStop (void)
{
Bool dummy;
- Platform::CloseSerialPort ();
_cpu->StopThread (dummy, dummy, kStopOnADime);
propertyChanged (cpuStatusChanged);
}
@@ -161,8 +159,6 @@
void Document::hotsync (void)
{
- Platform::SerialThreads(true);
-
CPUStopper stopper (kStopOnADime);
if (!stopper.Stopped())
return;
diff -ru -x BuildUnix Emulator_Src_3.0a2patched/SrcUnix/Platform_Unix.cpp Emulator_Src_3.0a2/SrcUnix/Platform_Unix.cpp
--- Emulator_Src_3.0a2patched/SrcUnix/Platform_Unix.cpp Mon Nov 15 16:31:09 1999
+++ Emulator_Src_3.0a2/SrcUnix/Platform_Unix.cpp Fri Nov 5 12:28:09 1999
@@ -37,9 +37,6 @@
bool gShowingDialog;
//static FILE * gCommHandle;
static int gCommHandle;
-static omni_thread *ReadThread = NULL;
-static omni_thread *WriteThread = NULL;
-static Bool terminate_threads;
// ===========================================================================
// ¥ TByteQueuePrivate
@@ -933,10 +930,8 @@
ErrCode Platform::OpenSerialPort (void)
{
PRINTF ("Serial Emulation (Unix): Attempting to open serial port...\n");
-
- ErrCode err = kError_NoError;
- if(SerialPortOpen()) return err;
+ ErrCode err = kError_NoError;
// Make sure the serial port is closed.
@@ -967,8 +962,7 @@
{
PRINTF ("Serial Emulation (Unix): No port selected in the Properties dialog box...\n");
}
-#if 0
- // moved to the StartSerialThreads call
+
if (gCommHandle)
{
PRINTF ("Serial Emulation (Unix): Creating serial port handler threads...\n");
@@ -981,50 +975,8 @@
PRINTF("OpenSerialPort: ReadThread=<%p> and WriteThread=<%p>\n", ReadThread, WriteThread);
}
-#endif
- return err;
-}
-/***********************************************************************
- *
- * FUNCTION: Platform::StartSerialThreads
- *
- * DESCRIPTION:
- *
- * PARAMETERS: none
- *
- * RETURNED: Error code for any errors that occur.
- *
- ***********************************************************************/
-ErrCode Platform::SerialThreads (Bool on)
-{
- PRINTF ("Serial Emulation (Unix): %s serial threads...\n",on?"starting":"stopping");
- if(on) {
- if (!SerialPortOpen()) {
- ErrCode err = OpenSerialPort ();
- if(err != kError_NoError) {
- PRINTF("Serial Emulation (Unix): OpenSerialPort fails!\n");
- return err;
- }
- }
- if (gCommHandle)
- {
- PRINTF ("Serial Emulation (Unix): Creating serial port handler threads...\n");
- terminate_threads = false;
- // Create the threads that will interact with the port. Make
- // them high priority threads.
- ReadThread = omni_thread::create( CommRead, NULL, omni_thread::PRIORITY_NORMAL );
- WriteThread= omni_thread::create( CommWrite, NULL, omni_thread::PRIORITY_NORMAL );
-
- PRINTF("OpenSerialPort: ReadThread=<%p> and WriteThread=<%p>\n", ReadThread, WriteThread);
- }
- } else {
- PRINTF("ReadThread is %s, WriteThread is %s\n",
- ReadThread?"running - will kill":"not running",
- WriteThread?"running - will kill":"not running");
- terminate_threads = true;
- }
- return kError_NoError;
+ return err;
}
@@ -1226,7 +1178,7 @@
void CommRead (void*)
{
PRINTF ("CommRead starting.\n");
- while (gCommHandle && !terminate_threads)
+ while (gCommHandle)
{
unsigned char buf[16];
long n = UART::GetRxQueue ().GetFree ();
@@ -1236,8 +1188,8 @@
{
// No space for new data, so don't read any.
- // This spams PRINTF ("no space\n");
-#if 0
+ PRINTF ("no space\n");
+#if 1
omni_thread* self = omni_thread::self();
if (self)
self->yield();
@@ -1315,7 +1267,7 @@
{
PRINTF ("CommWrite starting.\n");
- while (gCommHandle && !terminate_threads)
+ while (gCommHandle)
{
unsigned char buf[8];
long n = 0;
@@ -1329,14 +1281,6 @@
{
// Never mind, there really wasn't any data in the buffer
// (see note in TByteQueuePrivate::Put).
-
-#if 0
- omni_thread* self = omni_thread::self();
- if (self)
- self->yield();
-#else
- omni_thread::sleep( 0, 50000 ); // 10k nanoseconds = 1/100 sec
-#endif
continue;
}
Only in Emulator_Src_3.0a2patched/SrcUnix: SerialPatch
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]