16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-18 00:49:19 +02:00

verbose lpt logging

This commit is contained in:
milek7
2018-01-26 20:48:25 +01:00
parent 44515a5abb
commit c631f4beed
2 changed files with 19 additions and 7 deletions

View File

@@ -9,6 +9,7 @@ http://mozilla.org/MPL/2.0/.
#include "stdafx.h" #include "stdafx.h"
#include "LPT.h" #include "LPT.h"
#include "Logs.h"
// LPT na USB: // LPT na USB:
// USB\VID_067B&PID_2305&REV_0200 // USB\VID_067B&PID_2305&REV_0200
@@ -24,15 +25,21 @@ OutPortType OutPort;
bool TLPT::Connect(int port) bool TLPT::Connect(int port)
{ {
WriteLog("lpt: trying to connect lpt, port " + std::to_string(port) + "...");
// ladowanie dll-ki // ladowanie dll-ki
hDLL = LoadLibrary("inpout32.dll"); hDLL = LoadLibrary("inpout32.dll");
if (hDLL) if (hDLL)
{ {
WriteLog("lpt: inpout32 loaded");
InPort = (InPortType)GetProcAddress(hDLL, "Inp32"); InPort = (InPortType)GetProcAddress(hDLL, "Inp32");
OutPort = (OutPortType)GetProcAddress(hDLL, "Out32"); OutPort = (OutPortType)GetProcAddress(hDLL, "Out32");
} }
else else
return false; // MessageBox(NULL,"ERROR","Błąd przy ładowaniu pliku",MB_OK); {
WriteLog("lpt: failed to load inpout32");
return false; // MessageBox(NULL,"ERROR","Błąd przy ładowaniu pliku",MB_OK);
}
address = address =
port; //&0xFFFFFC; //ostatnie 2 bity mają być zerowe -> a niech sobie OUT-ują, gdzie chcą port; //&0xFFFFFC; //ostatnie 2 bity mają być zerowe -> a niech sobie OUT-ują, gdzie chcą
switch (address) // nie dotyczy 0x3BC switch (address) // nie dotyczy 0x3BC
@@ -45,10 +52,14 @@ bool TLPT::Connect(int port)
case 0xBD00: case 0xBD00:
OutPort(address + 0x006, 0); // 0xBC06? czysta improwizacja OutPort(address + 0x006, 0); // 0xBC06? czysta improwizacja
} }
WriteLog("lpt: port opened successfully");
return OutPort != 0; return OutPort != 0;
}; };
void TLPT::Out(int x) void TLPT::Out(int x)
{ // wysłanie bajtu do portu { // wysłanie bajtu do portu
WriteLog("lpt: sending data: " + std::to_string(x), logtype::lptdebug);
OutPort(address, x); OutPort(address, x);
}; };

9
Logs.h
View File

@@ -12,10 +12,11 @@ http://mozilla.org/MPL/2.0/.
enum logtype : unsigned int { enum logtype : unsigned int {
generic = 0x1, generic = (1 << 0),
file = 0x2, file = (1 << 1),
model = 0x4, model = (1 << 2),
texture = 0x8 texture = (1 << 3),
lptdebug = (1 << 4)
}; };
void WriteLog( const char *str, logtype const Type = logtype::generic ); void WriteLog( const char *str, logtype const Type = logtype::generic );