mirror of
https://github.com/fasteddy516/SimplySerial.git
synced 2024-11-24 10:04:35 +00:00
Finalized logging functionality. (Fixes #11)
This commit is contained in:
parent
ee5c91c5ff
commit
4f155da7b6
@ -12,7 +12,7 @@ namespace SimplySerial
|
|||||||
{
|
{
|
||||||
class SimplySerial
|
class SimplySerial
|
||||||
{
|
{
|
||||||
const string version = "0.5.0-beta.2";
|
const string version = "0.5.0";
|
||||||
|
|
||||||
static List<ComPort> availablePorts;
|
static List<ComPort> availablePorts;
|
||||||
static SerialPort serialPort;
|
static SerialPort serialPort;
|
||||||
@ -31,7 +31,7 @@ namespace SimplySerial
|
|||||||
static FileMode logMode = FileMode.Create;
|
static FileMode logMode = FileMode.Create;
|
||||||
static string logFile = string.Empty;
|
static string logFile = string.Empty;
|
||||||
static string logData = string.Empty;
|
static string logData = string.Empty;
|
||||||
static int bufferSize = 4096;
|
static int bufferSize = 102400;
|
||||||
static DateTime lastFlush = DateTime.Now;
|
static DateTime lastFlush = DateTime.Now;
|
||||||
|
|
||||||
|
|
||||||
@ -236,8 +236,8 @@ namespace SimplySerial
|
|||||||
start = DateTime.Now;
|
start = DateTime.Now;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
Thread.Sleep(1);
|
Thread.Sleep(1);
|
||||||
|
|
||||||
if (logging)
|
if (logging)
|
||||||
{
|
{
|
||||||
timeSinceRX = DateTime.Now - start;
|
timeSinceRX = DateTime.Now - start;
|
||||||
@ -247,7 +247,7 @@ namespace SimplySerial
|
|||||||
if (logData.Length > 0)
|
if (logData.Length > 0)
|
||||||
Output("", force: true, newline: false, flush: true);
|
Output("", force: true, newline: false, flush: true);
|
||||||
start = DateTime.Now;
|
start = DateTime.Now;
|
||||||
}
|
lastFlush = DateTime.Now;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -453,23 +453,6 @@ namespace SimplySerial
|
|||||||
ExitProgram(("Invalid log mode setting specified <" + argument[1] + ">"), exitCode: -1);
|
ExitProgram(("Invalid log mode setting specified <" + argument[1] + ">"), exitCode: -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// set size of logging buffer
|
|
||||||
else if (argument[0].StartsWith("logb"))
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
int newSize = int.Parse(argument[1]);
|
|
||||||
if ((newSize < 0) || (newSize > 100000))
|
|
||||||
throw new ArgumentOutOfRangeException("Log buffer size must be between 0 and 100000 bytes.");
|
|
||||||
else
|
|
||||||
bufferSize = newSize;
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
ExitProgram(("Invalid log buffer size specified < " + argument[1] + " > "), exitCode: -1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// specify log file (and enable logging)
|
// specify log file (and enable logging)
|
||||||
else if (argument[0].StartsWith("lo"))
|
else if (argument[0].StartsWith("lo"))
|
||||||
{
|
{
|
||||||
@ -528,7 +511,6 @@ namespace SimplySerial
|
|||||||
{
|
{
|
||||||
writer.Write(logData);
|
writer.Write(logData);
|
||||||
}
|
}
|
||||||
lastFlush = DateTime.Now;
|
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
@ -547,9 +529,12 @@ namespace SimplySerial
|
|||||||
static void ShowHelp()
|
static void ShowHelp()
|
||||||
{
|
{
|
||||||
Console.WriteLine($"\n<<< SimplySerial v{version} >>>\n");
|
Console.WriteLine($"\n<<< SimplySerial v{version} >>>\n");
|
||||||
|
Console.WriteLine($"{AppDomain.CurrentDomain.BaseDirectory}");
|
||||||
|
|
||||||
|
|
||||||
Console.WriteLine("Usage: ss.exe [-com:PORT] [-baud:RATE] [-parity:PARITY] [-databits:VAL]");
|
Console.WriteLine("Usage: ss.exe [-com:PORT] [-baud:RATE] [-parity:PARITY] [-databits:VAL]");
|
||||||
Console.WriteLine(" [-stopbits:VAL] [-autoconnect:VAL] [-log:LOGFILE] [-logmode:MODE]");
|
Console.WriteLine(" [-stopbits:VAL] [-autoconnect:VAL] [-log:LOGFILE] [-logmode:MODE]");
|
||||||
Console.WriteLine(" [-logbuffer:VAL] [-quiet]\n");
|
Console.WriteLine(" [-quiet]\n");
|
||||||
Console.WriteLine("A basic serial terminal for IoT device programming in general, and working with");
|
Console.WriteLine("A basic serial terminal for IoT device programming in general, and working with");
|
||||||
Console.WriteLine("CircuitPython devices specifically. With no command-line arguments specified,");
|
Console.WriteLine("CircuitPython devices specifically. With no command-line arguments specified,");
|
||||||
Console.WriteLine("SimplySerial will attempt to identify and connect to a CircuitPython-capable board");
|
Console.WriteLine("SimplySerial will attempt to identify and connect to a CircuitPython-capable board");
|
||||||
@ -568,8 +553,6 @@ namespace SimplySerial
|
|||||||
Console.WriteLine(" a device is disconnected / reconnected.");
|
Console.WriteLine(" a device is disconnected / reconnected.");
|
||||||
Console.WriteLine(" -log:LOGFILE Logs all output to the specified file.");
|
Console.WriteLine(" -log:LOGFILE Logs all output to the specified file.");
|
||||||
Console.WriteLine(" -logmode:MODE APPEND | OVERWRITE, default is OVERWRITE");
|
Console.WriteLine(" -logmode:MODE APPEND | OVERWRITE, default is OVERWRITE");
|
||||||
Console.WriteLine(" -logBuffer:VAL Number of bytes of data to buffer before writing to");
|
|
||||||
Console.WriteLine(" log file. Valid range is 0-100000.");
|
|
||||||
Console.WriteLine(" -quiet don't print any application messages/errors to console");
|
Console.WriteLine(" -quiet don't print any application messages/errors to console");
|
||||||
Console.WriteLine("\nPress CTRL-X to exit a running instance of SimplySerial.\n");
|
Console.WriteLine("\nPress CTRL-X to exit a running instance of SimplySerial.\n");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user