No print using unity3d free/inpout32 in windows 32 bits
Posted: Tue May 23, 2017 4:08 pm
Hi,
I write to Unity3D forum but no answer until now, then, maybe here I can have an insight.
I need send data to a parallel port in a game developed in Unity3d/C#; more specifically to an EEG,
but this equipament is in another city, then, I am trying to do the tests sending data to a printer,
on the same EEG environment: windows XP 32 bits, LPT1 at 0x378.
There is no more unity3d editor for 32 bits, then I am using Unity3D/C# under windows 10 64bits, and build for windows 32bits.
In a search I found inpOut32.dll at highRez and get the binaries inpOutBinaries_1501.zip:
- installed the inpOut32.dll in windows32 using install.exe in the packet
- copied inpOut32.dll to Unity/Editor, to Unity\Editor\Data\Mono\lib\mono\2.0​, to myProject/, to myProject/Assets/Plugins
- ​removed .dll from the DllImport syntax: "it should just be the library's name instead"
- restart Unity and build for windows 32bits
Blocks of code (based in packet examples):
[DllImport("inpout32")]
private static extern UInt32 IsInpOutDriverOpen();
[DllImport("inpout32")]
private static extern void Out32(short PortAddress, short Data);
[DllImport("inpout32")]
private static extern char Inp32(short PortAddress);
void Start ()
{
Debug.Log("SystemInfo.operatingSystem: "+ SystemInfo.operatingSystem);
Debug.Log("SystemInfo.operatingSystemFamily: " + SystemInfo.operatingSystemFamily);
Debug.Log("SystemInfo.processorCount: " + SystemInfo.processorCount);
Debug.Log("SystemInfo.processorFrequency: " + SystemInfo.processorFrequency);
Debug.Log("SystemInfo.processorType: " + SystemInfo.processorType);
Debug.Log("SystemInfo.deviceModel: " + SystemInfo.deviceModel);
Debug.Log("SystemInfo.deviceName: " + SystemInfo.deviceName);
Debug.Log("SystemInfo.deviceType: " + SystemInfo.deviceType);
definePortAccess(0x378);
Debug.Log ("inpOut print 1");
Write (1);
Debug.Log ("status LPT: " + Read ());
Debug.Log ("inpOut print 2");
Write (2);
Debug.Log ("status LPT: " + Read ());
}
private bool _X64;
private short _PortAddress;
public void definePortAccess(short PortAddress)
{
_X64 = false;
_PortAddress = PortAddress;
uint nResult = 0;
nResult = IsInpOutDriverOpen();
Debug.Log("nresult = "+ nResult);
}
public void Write(short Data)
{
Out32(_PortAddress, Data);
}
public byte Read()
{
return (byte)Inp32(_PortAddress);
}
Executing in windows 32bits:
nResult=1,
Write (1); Write (2): no print and data light button off (using notepad editor I can print)
What am I doing wrong? Any tips? Some directions?
Thanks in advance
I write to Unity3D forum but no answer until now, then, maybe here I can have an insight.
I need send data to a parallel port in a game developed in Unity3d/C#; more specifically to an EEG,
but this equipament is in another city, then, I am trying to do the tests sending data to a printer,
on the same EEG environment: windows XP 32 bits, LPT1 at 0x378.
There is no more unity3d editor for 32 bits, then I am using Unity3D/C# under windows 10 64bits, and build for windows 32bits.
In a search I found inpOut32.dll at highRez and get the binaries inpOutBinaries_1501.zip:
- installed the inpOut32.dll in windows32 using install.exe in the packet
- copied inpOut32.dll to Unity/Editor, to Unity\Editor\Data\Mono\lib\mono\2.0​, to myProject/, to myProject/Assets/Plugins
- ​removed .dll from the DllImport syntax: "it should just be the library's name instead"
- restart Unity and build for windows 32bits
Blocks of code (based in packet examples):
[DllImport("inpout32")]
private static extern UInt32 IsInpOutDriverOpen();
[DllImport("inpout32")]
private static extern void Out32(short PortAddress, short Data);
[DllImport("inpout32")]
private static extern char Inp32(short PortAddress);
void Start ()
{
Debug.Log("SystemInfo.operatingSystem: "+ SystemInfo.operatingSystem);
Debug.Log("SystemInfo.operatingSystemFamily: " + SystemInfo.operatingSystemFamily);
Debug.Log("SystemInfo.processorCount: " + SystemInfo.processorCount);
Debug.Log("SystemInfo.processorFrequency: " + SystemInfo.processorFrequency);
Debug.Log("SystemInfo.processorType: " + SystemInfo.processorType);
Debug.Log("SystemInfo.deviceModel: " + SystemInfo.deviceModel);
Debug.Log("SystemInfo.deviceName: " + SystemInfo.deviceName);
Debug.Log("SystemInfo.deviceType: " + SystemInfo.deviceType);
definePortAccess(0x378);
Debug.Log ("inpOut print 1");
Write (1);
Debug.Log ("status LPT: " + Read ());
Debug.Log ("inpOut print 2");
Write (2);
Debug.Log ("status LPT: " + Read ());
}
private bool _X64;
private short _PortAddress;
public void definePortAccess(short PortAddress)
{
_X64 = false;
_PortAddress = PortAddress;
uint nResult = 0;
nResult = IsInpOutDriverOpen();
Debug.Log("nresult = "+ nResult);
}
public void Write(short Data)
{
Out32(_PortAddress, Data);
}
public byte Read()
{
return (byte)Inp32(_PortAddress);
}
Executing in windows 32bits:
nResult=1,
Write (1); Write (2): no print and data light button off (using notepad editor I can print)
What am I doing wrong? Any tips? Some directions?
Thanks in advance