Inpout32 Dll Serial Port Examples Of Similes
• Introduction This is a good tutorial about interfacing with the parallel port; more inportantly reading from the port. Other articles I've seen only shown how to write to the port.
InpOut32 is a windows DLL and Driver to give direct access to hardware ports (for example the parallel and serial port from user level programs. Welcome to the. His previous post about 'opening the serial port'. I'm using inpout32.dll on a Windows 7. Pointers (messy but fine for an example.
Before I get ahead of myself, the parallel port I used is an ECP (Extended Capability Port). Find out if your port is the same as mine, yours could be an EPP or SPP. Go to “Control Panel / System / Hardware Tab / Device Manager / Ports (Com & LPT) / Printer Port (LPT1 or LPT2) /” It should indicate what type you have. You can also go to the ‘Resource’ Tab to indicate the range of your port: mine is I/O Range 0378 – 037F, ignore the other I/O range. For the ECP, there are some over headers if I was to use the data port as both input and output. Instead, I used the signal port for data processing.
If by any odd reason you don't understand the tutorial. Please refer to the explaination towards the bottom of the page. Or just email me. Note that all information regarding the inpout.dll is on Please Vote so I can get an indication weither it's worth my time to update. Member 10721558 3-Apr-14 21:47 3-Apr-14 21:47 Hi, This is wrt to your tutorial - Since I am new in this field. Hence, I decided to try out the source code that you have provided in the site.
However, it doesnot provide the required results. I am trying all sort of programs and techniques to run the parallel port, but have not achieved any success till now. I would like to mention, for your kind information that - I downloaded the Inpout32.dll and pasted it in windows/sys32 folder.
I have also checked the port address, and it matches with the program. I am using Microsoft Visual Studio 2005.
The error Message Reads- An Unhandled exception of type 'System.Runtime.InteropServices.SEHException' occured in Port-testing.exe Additional information: External component has thrown an exception I am stuck in this problem for a few days now. I would be very happy if you can help me in this regard. Member 10721558 3-Apr-14 4:16 3-Apr-14 4:16 I am new to Visual Studio. Hence, a trivial problem. First, when I create a new project through Windows Form Applications- the code editor (Form1.vb) looks quite different from the one shown in the tutorial. Actually, it has a lot of other things added.
Also, the solution explorer shows a whole lot of other programs created. And the same program when I type in the produced file creates whole lot of error I require help in this. I am stuck in using inpout32.dll for parallel port programming for a very long time. Lukeer 12-Jul-12 21:16 12-Jul-12 21:16 Hi phebejtsov, thank you for sharing this article. It helped me a lot building an application that reads the parallel port's status.
The application works on my developer PC. I'm primarily interested in 1 digital input and chose BUSY for that. A relais (switch side, not coil side) connects BUSY to GND. With inactive relais, as well as without anything plugged in the port, my application reads 0x78 from the port.
Activation of the relais changes that to 0xF8. However, it doesn't work on the target PC. Instead of returning 0x78 from an untouched parallel port, it returns 0x79. Activating the relais doesn't change anything. No exceptions, error messages or anything point me somewhere.
On the target machine, I don't have administrative rights. Does that hinder from using inpout.dll? I'm using inpout32.dll, version 1.0.0.1, 32768 Bytes. Have you heard of such a problem before? Do you know of a solution? Kamrul10 2-Oct-11 4:14 2-Oct-11 4:14 Hello, I run this project in my computer with VB.net 2005.
When click to button1 with this event Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Out(&H378S, &HFFS) 'Print '1' to D7-D0 or 255 in Decimal Dim Value1 As String 'String named Value1 Value1 = Inp(&H378S) 'Now Value1 has the values in 'data port' MessageBox.Show(Value1) 'A popup will indicate the current value written End Sub I found 120 result, but not found 255 in decimal. Could you please say me about this problem. Thanks and Regards Md Kamrul Islam. Actually, I am using the same project with the same code, Private Sub Button1_Click( ByVal sender As System. Object, ByVal e As System.EventArgs) Handles Button1.Click Out(&H378S, &HFFS) ' Print '1' to D7-D0 or 255 in Decimal Dim Value1 As String ' String named Value1 Value1 = Inp(&H378S) ' Now Value1 has the values in 'data port' MessageBox.Show(Value1) ' A popup will indicate the current value written End Sub The result still 120 instead.
Actually it's not clear for me what is the solution that you mean Thankx & Regards Mustafa. Quote:[.] value of 120. [.] The answer is that Bit 7 (S7) of the signal port is inverted! (Ahhhhh) and S7 - S3 are always high enable [.]For me, this one worked int inputState = Inp(0x378 + 1) ^ 0x78;Where 0x378 is the I/O base address. Use it directly for output, add one for input. XOR the result with 120(dec) or 78(hex) to get a byte whose every bit represents an unchanged (0) or changed (1) input pin with respect to its electrical behaviour.
Be sure to use the electrical side correctly. Some of the pins must be connected to GND to change, some need to be connected to +Ub.
Ok, this is for the Status Port, But my problem is with the Data Port again with the code, the following code I'm using for the data port, the results should be 255 but I got 120. Private Sub Button1_Click( ByVal sender As System. Object, ByVal e As System.EventArgs) Handles Button1.Click Out(&H378S, &HFFS) ' Print '1' to D7-D0 or 255 in Decimal Dim Value1 As String ' String named Value1 Value1 = Inp(&H378S) ' Now Value1 has the values in 'data port' MessageBox.Show(Value1) ' A popup will indicate the current value written End Sub Thanx.
Saddam Khan 20-Sep-11 18:33 20-Sep-11 18:33 Hello Sir, I am really inspired by ur project and i appreciate ur efforts, My Question in Detail: I made two modules in VB regarding Inp and Out done programing, then i send the output to parallel port and i use inp function to get that value from sended port address, it seems my signals are reaching at the port. But i am still not confirming while they are reaching there or not, please inform me any simulator that detects signals in parallel port, Secondly whenever i try to boot up my PC all Pins are on High, Even when i place One LED leg at controle Pin and One at Ground Still my LED Lights Up (Which should not be done) Please show me a way that my LED only Lights Up on Certain Pins whom i give instructions from my Program otherwise these pins should be Off( not high as always). I think there is nothing wrong from programing side but the problem is with hardware that is always active and lights up LED everytime before my instructions and also my if i send &H0 it also doesnot work and doesnot disable the datapins. Please help me urgently. Saathis 27-Apr-11 0:53 27-Apr-11 0:53 Hi bro. Here im saathis final year student implementing speech door access system in vb6. How to make sound to text then text to parallel port data high & low.
If user say his password that fixed in database. It will check then D1 of port goes to high and rotate the motor to open the door. Same process for close operation. How to build it in VB6. Please help me info: microsoft access 2007 for database platform. Use USB to parallel 25 pin since my laptop don't have parallel port.
Please help me bro. Saathis 27-Apr-11 0:53 27-Apr-11 0:53 Hi bro. Here im saathis final year student implementing speech door access system in vb6.
How to make sound to text then text to parallel port data high & low. If user say his password that fixed in database. It will check then D1 of port goes to high and rotate the motor to open the door.
Same process for close operation. How to build it in VB6. Please help me info: microsoft access 2007 for database platform. Use USB to parallel 25 pin since my laptop don't have parallel port. Please help me bro. Dannydy 29-May-07 22:53 29-May-07 22:53 hi I'm new here,recently i'm doing my project on parallel port,using the parallel port to control my motor,i used vb 6.0, i've read the inpout32.dll,for write to the port, the portaddress was 888, whereas read from the port,portaddress was 889. The output of the pin are working fine.now i stunt on the input of the parallel port.
How do i get feedback from the input of the parallel port while it's on high(1).because i'm using sensor the track the movement of the motor.could anyone tell me what's the solution.thanks. I have been using a couple of 1.5 batteries to get a 3 volt source. I connect that between a ground pin and whichever status pin. What was high becomes low, low becomes high, whilst ever the battery is connected to a particular pin. This all seems to work fine, unless all the data pins D0 - D7 are on high. Then this stops working, I dont know why just yet.
-- modified at 4:17 Thursday 5th July, 2007 also my status port seems back to front from the example, the value returned from status port with no connections on parallel port anywhere is 135, the exact opposite. 10000111 Last Visit: 31-Dec-99 19:00 Last Update: 29-Dec-17 2:07 1 General News Suggestion Question Bug Answer Joke Praise Rant Admin Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.
Hi All, I am reviving my efforts to communicate to an instrument via a COM (Serial) port, using QB64 v1.00 running on a Window 7 machine. As some may recall, I have installed the 64 bit version of the ironically named INPOUT32.DLL, and I am trying to open the COM1 port, read status registers and read and write to the port. I have been able to do this, but ONLY while another (third party) program has opened the port for me. I cannot do this using with only QB64 and INPOUT32.DLL. As a reminder, a snippet of my initial message is pasted below.
I very much suspect it is an issue with Windows 7, or just something missing from the DLL required to open the port in Windows 7. I have since confirmed that the problem is NOT the Anti Virus I use at work, and I have also tried various hardware handshaking configurations and manually pulling up/down control lines on the port. Still, the only way QB64 successfully communicates with the port is with the third party software running.
I also know that I can write to and read from the port using VBA from Excel 2010, and have successfully tested it, but I would like to be able to use QB64. Catia Symbols Font Character. SO, HAS ANYONE HERE SUCCESSFULLY OPENED AND COMMUNICATED WITH A SERIAL PORT ON A WINDOWS 7 MACHINE USING QB64? Have you been able to write to and read from a connected device? I would very much like to hear from someone who has success in doing this and use their code and setup as an example. Thanks a ton in advance, Dan -------------------------------------------------------Earlier message------------------------------------------------ First of all THANK YOU all, and particularly Galleon, very much for developing and supporting QB64. I am a bit of a Luddite, preferring to use BASIC for my programming needs. I've long preferred QB45, since I can spend less time learning programming environments and setting software up on my machine, and more time getting it to work do to do the things I need it to do.
QB64 has been extremely useful. I am attempting to use QB64 (v 1.00) on a Window 7 machine with an on-board COM port (i.e. Hardware port, not a USB adapter) to talk to a voltmeter via serial port. I am having trouble opening the port. I can get it to work, but conditionally. I have located and installed the 64 bit update to inpout32.dll from the latest package at (this is an update from the earlier inpout32.dll made by Logix4u).
I am using the code described on the QB64 wiki here: to open the COM port by sending bit-level commands to the UART ports as shown in the code immediately under 'COM Ports' halfway down the page. And, everything works, BUT ONLY after I have loaded the free serial port test program here: microridge.com/comtestserial.htm (I have no interest in this program and am not advertising for it. It just happens to be the first one I found that works). With that test program I can send characters to the COM port and change it's state manually. If I run my QB64 program concurrently, I can do the same.
As soon as I shut down the test program, I can no longer do anything with the COM port from Basic. I also wrote the code attached below to continuously query the UART registers of COM1. It seems to work fine, returning the values of the bytes associated with the COM port, but again, only when the serial test port program is running. Once I stop that test program, the values returned by my QB64 program are all 255, i.e.
It doesn't seem to be able to read the port. SO, do you have any suggestions as to what is going on and how to fix it? Is the COM1 address of 0x3F8 associated with some 'virtual port' in windows which can be explicitly opened? Is that what the COM test program is doing? I would prefer not to have to run external programs to enable by QB64 code to run. Thanks for your help and advice. Quote And, everything works, BUT ONLY after I have loaded the free serial port test program here: microridge.com/comtestserial.htm (I have no interest in this program and am not advertising for it.
It just happens to be the first one I found that works). With that test program I can send characters to the COM port and change it's state manually. If I run my QB64 program concurrently, I can do the same. As soon as I shut down the test program, I can no longer do anything with the COM port from Basic. Hi Clippy, I really do appreciate your continued help, but what you are telling me doesn't make sense on one level - please hear me out. In the most basic configuration, a serial port can be configured as a simple software-handshaking-only communications line.
See the document here, and referred to in the QB64 wiki page: In the third section down, the wiring for a 'null model without handshaking' is shown. This is what I am using. This is exactly what my instrument does. It's exactly what an ADM 3A 'dumb terminal' did on the serial line 30 years ago 'in full duplex mode' - it prints the character received on its Rx line (Tx on the PC end) and echoes it back on the Tx line (Rx on the PC end).
BUT, I don't need an instrument connected to know that nothing is being sent on the Tx line. I have an indicator block with LEDs showing the Tx, Rx, DTR, RTS, CTS, etc. Status lines and I have Tx connected to Rx.
I can see the Tx/Rx LEDs blink when command is successful. It is one reason I am trying to operate the port at 300 baud (though I can still see the blinking at 9600).
Furthermore, the instrument in question (a $4000 Keithley 2400 Source-Meter) has only software handshaking. So, if it cannot even get a single character from the port, there is not going to be any communication. I need to be able to send ASCII to it. But this is a red herring. The meter AND the port both work.
I've verified that a dozen times, including using VBA from Excel to do so. AND QB64 works just fine, as the code below proves, BUT ONLY if the port is 'opened' or otherwise enabled by some third party app. I have included the whole code below. I also added the line 'OUT32 Baseadd% + 4, &H10' as you suggested. It was actually already in there, but I added it twice within the loop for good measure. Still, there is no reading any of the UART registers, nor sending any characters out the port so long as the third party app does not have the port open.
I think QB64/INPUT32.DLL is simply failing to open the port. Please run this code (with a null modem cable or some other serial device on the port) and tell me if you get anything other than 255 returned from the UART registers. Some other pieces of evidence: I have my third party serial port test app.
When I run it first, I get no error from QB64 telling me the port is already open. Conversely, when I run QB64 first, I get no error from the test port app telling me the port is already open. I DO get a warning in the app if the port has been previously opened by another app, say within VBA/Excel. Also, after my tests with Excel, the port appears to have gotten 'stuck'.
I could not get the third party app to open it, and my QB64 code worked with no problem. I re-booted to clear the port and all is I have been describing. QB is just not opening the port properly (and to be clear - by 'port' I mean the UART - setting the registers for the correct baud rate and status, etc., and reading the registers back). Note that INP32 and OUT32 are working. When the port is opened, I can correctly read the registers.
If using the test app I change the Baud rate of the port, the returned values from Baseadd% + 1 are correct, and the baud rate is correctly displayed by my QB64 program. So, to summarize, there effectively *IS* a device connected to the serial port. It's a simple loopback with LED indicators. But I can't even get to the point of sending a character out the port because I can't set or read the UART registers (i.e.
'open' the port), UNLESS there is a third party app running to do so. After that, everything works as expected and I am reading/writing to the UART correctly. So, I would like to try to figure out why I can't do this properly with QB64/Inpout32.dll but I can with Excel/VBA. So, please have a good look at my code below and try to run it, and see what you get.
If you've got an old modem lying around plug that in for good measure, but I argue, except for the Tx-Rx loop back, that you don't need it. Thanks for reading through.
Code: REM COMRegisterScan.bas: Scan registers associated with open COM REM port continously, to spot changes. 'DECLARE DYNAMIC LIBRARY 'inpoutx64' DECLARE DYNAMIC LIBRARY 'inpout32' FUNCTION Inp32% (BYVAL PortAddress AS INTEGER) SUB Out32 (BYVAL PortAddress AS INTEGER, BYVAL Value AS INTEGER) END DECLARE Baseadd% = &H3F8 'COM1 REM Possible port addresses are &H3F8(1016) = COM1, &H2F8(760) = COM2, &H3E8(1000) = COM3 and &H2E8(744) = COM 4. Out32 Baseadd% + 4, &H10 'Loopback on (&H1) AND DTR, RTS high (&H03). CLS Print 'Scanning comp port registers.
ESC to quit.' PRINT print 'reading from base address: ';Baseadd% Out32 Baseadd% + 4, &H10 'Put UART in loopback mode. Clippy Diagnostic. DO Locate 10, 1 Print ' Divisor Latch Bytes: '; Out32 Baseadd% + 3, &H80 'Set DLAB high to access Baud bits lb% = Inp32(Baseadd%) 'Low byte.
Hb% = Inp32(Baseadd% + 1) 'High byte. Out32 Baseadd% + 3, &H00 'Reset DLAB.
Out32 Baseadd% + 4, &H10 'Put UART in loopback mode. Clippy Diagnostic. Print lb%, hb%; 'Print bit values.
Divisor& = lb% + 256 * hb% 'Calculate Baud rate divisor. PRINT ' Baud Rate: '; 115200 / divisor& 'Print Baud rate. Print 'Interrupt Identification Register: '; Inp32(Baseadd% + 2); ' ' Print ' Interrupt Enable Register: '; Inp32(Baseadd% + 1); ' ' Print 'Interrupt Identification Register: '; Inp32(Baseadd% + 2); ' ' REM NOTE: FIFO control register also at Baseadd%+2 is write only. Print ' Line Control Register: '; Inp32(Baseadd% + 3); ' ' Print ' Modem Control Register: '; Inp32(Baseadd% + 4); ' ' Print ' Line Status Register: '; Inp32(Baseadd% + 5); ' ' Print ' Modem Status Register: '; Inp32(Baseadd% + 6); ' ' REM Scratch Register Test before% = inp32(Baseadd% + 7) 'Read the scratch register.
After% = before% - 1 'Change the value. Out32 Baseadd% + 7, after% 'Try to write the new value. After% = inp32(Baseadd% + 7) 'Reread the register.
PRINT ' Scratch Register Test: '; if after% = before% then 'If it's unchanged, then Color 4 'warn in red that we Print 'FAIL' 'can't write to COM, else 'otherwise Print 'PASS' 'we're ok. End if ' color 7 'Reset to white. X$ = INKEY$ IF x$ = CHR$(27) THEN EXIT DO 'Escape key quits IF x$ = 'F' THEN Out32 Baseadd% + 4, 13 'F' to force loopback, RTS, DTR high. IF x$ = 'f' THEN Out32 Baseadd% + 4, 00 'f' to force loopback, RTS, DTR low. Sleep 1 Out32 Baseadd%, &HFF 'Send ASCII null (all 1's) to the port. Hi Clippy, Ok, good Idea.
I tried it just now. Doesn't work at all.
My code returns numbers varying from 253 to 254 and does not change whether or not the port is opened by the third app. I don't even think the reads are getting the bits right in this case.
Interestingly (frighteningly?), the 'original' version of INPUT32.dll is by logix4u.net and that website is DOWN. But it was available as recently as a month ago. It may have bitten the dust, so now is the time to hoard that DLL if you haven't arlready done so. There are still a few mirror sites on-line that have it. Phil, from, wrote the 'modified' INPOUT32.DLL, which as he states, runs both 32 and 64 bit versions as determined at run-time. There are some other functions in his version and I was able to use calls to those to confirm that I was loading the correct DLL.
I would get errors when loading the 'original' version and commented out the function call. So I was able to verify I am running the 'original' version, the modified version is the only one that works on my Win7 machine. The true 64 bit version doesn't run with QB64 (which is running in 32 bit mode). So, still very puzzling. I am beginning to think I am doomed to opening up putty and leaving it on while I try to access the serial port using QB64. Or, I will have to learn how the drivers work, and write a new one, which I am not looking forward to.
Thanks, Dan I am in touch with Phil by the way, and he is not familiar with QB64, so was not able to help from that angle. He did sensibly suggest that I ask on the MSDN forums, and I did so on the Visual Basic Forum, and was immediately rebuffed for an 'off-topic' message (QB64 is not Visual Basic) and my post was essentially moved to the trash. That was not helpful. Hi All, I just figured I would send an update on my attempts to access the COM port via QB64 on Windows 7.
There is nothing really new here - I am still stuck. I now have an instrument connected, and I can communicate with it.
I 'open' the COM port on the bit-level of the UART following the procedures in the wiki here.and it works fine. I can write to and read from the instrument, BUT ONLY if there is a third party program, like a COM port monitor, 'opening' the port for me. Once that third party app is closed, all communication with the COM port via QB64 ceases. The problem with having the third party app open (eg. Putty) is that it's looking at the COM port and trying to read it as well, so some of the characters sent by the connected instrument are read by my QB program and some are grabbed by putty. This is especially true at higher buad rates, so I've had to work at 300 buad to troubleshoot. But I've found a very nice workaround.
I execute the following code in powershell to open the port. Code: $port= new-Object System.IO.Ports.SerialPort COM1,300,None,8,one $port.Open() So the PS code 'opens' the port (somehow it allows the QB INPOUT32.DLL libraries to access the UART) and all the rest is done by my QB64 code. I can even change the baud rate on the fly. Since I access the UART on the bit level it does not matter what the PS 'open' command did initially.
Since the PS script just sits there, and there is no attempt to try to read from the COM port, there is no conflict with the returned data stream. QB64 has full control over the port until I type $port.close() in Powershell. If I can't figure out what is going on, one semi-permanent workaround is to include a _SHELL command in QB64 to invoke a Powershell script that opens the port for me, but I will have to close it manually when I done with QB.
AND NOW A SHOUT OUT TO USER PETE. Are you here? A while ago (2010) you posted () that you had succeeded in communicating with the COM port in Windows 7 but it was a 'pain in the ASCII'! Do you remember how you did this? Can you give a quick summary of the steps you took?
I'd really like to know in case I am missing something in all my efforts. Thanks everyone for all the help so far. Though I haven't really figured out what is going wrong with the COM port access, I have at least been able to get enough workarounds going to start to do what I set out to do, and that is to communicate with serial-port-connected instruments. Hi Pete, Thanks for the reply.
It sure is looking like it's a Windows 7 issue. I am just wondering if it is only so on *my* machines and if others managed to get COM port access on their machines without so many issues. Was there anything special you needed to do on your Win 7 machine to make the COM program work? Registry key settings?
I've confirmed my problem is NOT the Anti Virus on the system, as I have the same problems at home. For 'amateur programmers', QB64 is a pretty spiffy package.