No print using unity3d free/inpout32 in windows 32 bits

My x64 port of InpOut32
Post Reply
josiperez
New User
Posts: 2
Joined: Mon May 22, 2017 11:22 pm

No print using unity3d free/inpout32 in windows 32 bits

Post by josiperez » 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

User avatar
phil
Site Admin
Posts: 5145
Joined: Sun Apr 06, 2003 11:12 pm

Re: No print using unity3d free/inpout32 in windows 32 bits

Post by phil » Tue May 23, 2017 4:14 pm

I don't think writing 1 and 2 to the parallel port is going to have much effect on a printer, wouldn't you need to write printer commands and data?
The real question is, are the data pins even changing - I don't suppose you can test that easily with a multi meter or something?

How have you setup the parallel port (ECP, ECC, etc.) - are the input and output registers in bi-directional mode, otherwise you have 2 separate ports, one for writing (output) and one for reading (input). I don't know how familiar you are with LPT ports (I used to know a bit 23 years ago but I cant remember much from that time now!) normally a printer would use the status port not the data port.
--[ Phil ]--
--[ Administrator & XMBC Author ]--
Logitech G9, Logitech MX518, Microsoft Intellimouse, Trust 16341 BT Mouse
Windows 10 x64, Intel i5-6600k, Asus 170-A, 16GB DDR4,
nVidia GeForce GTX 970, 2xEvo 850 (RAID 0), 2x2TB WD Black (RAID1)

josiperez
New User
Posts: 2
Joined: Mon May 22, 2017 11:22 pm

Re: No print using unity3d free/inpout32 in windows 32 bits

Post by josiperez » Tue May 23, 2017 5:04 pm

Thank you very much for your fast answer.
I will try to send PCL commands (good tip) - I wrote 1 and 2 because to the EEG I will need send just numbers from 1 to B depending on conditions.

I am not familiar with LPT ports. Until now I used print, printf or something like that to send data to the parallel or to the usb port! But yes, it is clear now, I need warn the printer that I am sending data, I am not under a printer environment taking care of that.

In the BIOS, I left ECP+EPP, understanding that the system will choose the apropriate method. I don't know if the cable is bidirectional or not, and I conclude for your answer that is better not Read() while i don't know that.

Thanks again: I have a direction now.

User avatar
phil
Site Admin
Posts: 5145
Joined: Sun Apr 06, 2003 11:12 pm

Re: No print using unity3d free/inpout32 in windows 32 bits

Post by phil » Tue May 23, 2017 7:08 pm

Regarding ECP/EPP, If I recall, there is a register port on 37x that can set the mode. I'm sure there are some resources online about how to program the parallel port and I suspect google will be better at finding them than me :).

Good luck and let me know how you get on.
--[ Phil ]--
--[ Administrator & XMBC Author ]--
Logitech G9, Logitech MX518, Microsoft Intellimouse, Trust 16341 BT Mouse
Windows 10 x64, Intel i5-6600k, Asus 170-A, 16GB DDR4,
nVidia GeForce GTX 970, 2xEvo 850 (RAID 0), 2x2TB WD Black (RAID1)

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest