How do I access interrupts in Visual Basic
Page 1 of 110 Replies - 8897 Views - Last Post: 22 August 2012 - 05:36 AM
#1
How do I access interrupts in Visual Basic
Posted 03 February 2008 - 04:57 PM
This forum suggested I change to VB.net for some reason. Can VB.net access interrupts or what are the advantages of VB.net. What will that cost me? Will I have to junk all the working code and subroutines that I use in Visual Basic? Just suggesting a different language is not an answer to a specific question. If it is impossible, just say so. Why did MS have to change what was working rather than just make it better? (that last question is just rhetorical and isn't expecting an answer)
I just want to access interrups in Visual Basic. I found one downloadable package that (almost) works, but only returns one byte (max 255) not the whole thing.
Too many questions? Too few answers. Impossible, so it seems ... is anybody out there smart enough to have accessed interrupts from Visual Basic (version5) ? HOW?
Replies To: How do I access interrupts in Visual Basic
#2
Re: How do I access interrupts in Visual Basic
Posted 03 February 2008 - 09:49 PM
#3
Re: How do I access interrupts in Visual Basic
Posted 04 February 2008 - 11:28 AM
#4
Re: How do I access interrupts in Visual Basic
Posted 04 February 2008 - 11:39 AM
The purpose is to send commands out the printer port to control a device attached to that port. The application I am trying to move to Visual Basic (from Quick Basic) is an application that controls a model train using DCC (Digital Command Control). By sending various signals to the DCC, the model train locomotives can be started, stopped and various lights and whistles can be controlled on the locomotives. Because it is a digital system, several model engines and their accessories can be controlled at the same time and one computer can also control the entire model railraid including all switches and building lights and signaling, etc.
DCC is well established, but using a PC computer to control it all is still developmental.
I expect this ability to send values via the interrpup can also be used to control other robotic systems such as radiation field scanners for physics applications and perhaps even for robotic hobbiests.
But first I need to know how to send via an interrupt and read the result of that port. Sort of like the Quick Basic INP and OUT command.
#5
Re: How do I access interrupts in Visual Basic
Posted 04 February 2008 - 07:27 PM
If you want to access IO directly, you must you a kernel mode driver, and you're probably not in the mood for writing one of those, and you can't really do it in VB anyway.
There is however, a nice bunch of people that in their infinite kindness wrote an ActiveX DLL that you can use from VB to control the port. Their DLL includes it's own kernel mode driver. That DLL can be downloaded here.
Just download the file (Inpout32.dll), and keep it in the same directory as your project.
You can then declare the Inp and Out functions in a seperate BAS file like so:
Public Declare Function Inp Lib "inpout32.dll" Alias "Inp32" _ (ByVal PortAddress As Integer) _ As Integer Public Declare Sub Out Lib "inpout32.dll" Alias "Out32" _ (ByVal PortAddress As Integer, _ ByVal Value As Integer)
By the way, those aren't actually interrupts. Interrupts are a different thing.
Oh, and to access the port from VB.net would be using exactly the same method.
This post has been edited by Nayana: 04 February 2008 - 07:26 PM
#6
Re: How do I access interrupts in Visual Basic
Posted 05 February 2008 - 12:33 AM
HOWEVER. .. it returns a single integer from the interrupt port
as in : Public Declare Function Inp Lib "inpout32.dll" Alias "Inp32" _
(ByVal PortAddress As Integer) As Integer
RATHER THAN, the expect type of value as follows:
Public Type RegType AX As Integer ' installed BX As Integer ' mode CX As Integer ' nActive DX As Integer BP As Integer SI As Integer DI As Integer Flags As Integer End Type Public inRegs As RegType Public outRegs As RegType Public PortNumber As String ' port being eg: &70h Public ValueFromPort As String ' hexadecimal Public ValueToPort As String
The various .AX .BX . CX etc. each contain different bits of information that are needed for a returned value from a parallel port. This InpOut32.DLL routine returns (as far as I can tell) only the one single integer.
The following code snippit shows how I'm expecting to be able to use the various items in the data type (as in this modified old DOS routine).
___________
1112 Select case iOption Case 1 1120 inRegs.AX = &H1 'turn system on Call INTERRUPT(&H70, InRegs, OutRegs) Exit Sub Case 2 1130 inRegs.AX = &H0 'turn system off Call INTERRUPT(&H70, InRegs, OutRegs) Exit Sub ' Case 3 and 4 not shown in this example) Case 5 ' do nothing Exit Sub Case 6 'DCC reset 1350 inRegs.AX = &H100 Call INTERRUPT(&H70, InRegs, OutRegs) 'f OutRegs.AX = 0 Then Print " DCC SYSTEM RESET " 'If OutRegs.AX < 0 Or OutRegs.AX > 0 Then Print " RESET UNSUCCESSFUL" 'Print " ANY KEY WILL CONTINUE FROM RESET" 1355 'A$ = INKEY$: If A$ = "" Then GoTo 1355 'CLS exit sub End select Exit Sub
__________________
(indents and leading spaces don't seem to be allowed in this post - so the above snippet is not formatted with indents for readablity - Sorry)
_________________________
I still would like to find a way to access the interrups and get back information of the 'RegType' type as described above.
There was another package that I found on the interenet that I downloaded called VBASM that had the expected data type structure, but I couldn't get it to work. Evidentally the .DLL was incompatibel or maybe I needed to'register' the .DLL (I don't know how to do that) Have you happened to have tried the VBASM code to accomplish access to interrupts in Visual Basic? That seems closer to what I need, but I can't get it to work.
Thanks for your helpful suggestion, but I'm still stuck.....
#7
Re: How do I access interrupts in Visual Basic
Posted 05 February 2008 - 01:02 AM
I haven't actually tried the code (and I can't) because I don't have a parallel port.
I also haven't read the docs, but I assume that the Integer should have all the information you need in it. Remember you can access all the bits in the Integer seperately.
Like:
If myInt And 1 Then 'bit 0 is set ElseIf myInt And 2 then 'bit 1 is set ElseIf myInt and 4 Then 'bit 2 is set ElseIf myInt and 8 Then 'bit 3 is set ElseIf myInt and &H10 Then 'bit 4 is set
and so forth. With &H20,&H40,&H80,&H100 etc.
&Hxxx in basic means xxx is in hexadecimal format.
You could also check it with a function like this
Function BitIsSet(value As Integer, bit As Integer) As Boolean Return (value And 2 ^ bit) > 0 End Function
#8
Re: How do I access interrupts in Visual Basic
Posted 05 February 2008 - 01:48 AM
Using the InpOut stuff I usually just get back a single integer rather than anything that would fit into the "type" structure. I can surely look at the separate bits in the integer, but I don't think that is what I need to do.
Are you suggestion that ...
With &H20,&H40,&H80,&H100 etc. might be the separate part of the type structure that I am looking for. I don't think so, but I am still trying anything I can.
The vbASM from Softcircuits (from about 10 years ago?) seems to be 16 bit and maybe that is why it won't work in Visual Basic (32-bit ?) I'm still searching the internet for something that might work.
Let me know if you have an ideas to solve this.
#9
Re: How do I access interrupts in Visual Basic
Posted 05 February 2008 - 02:58 AM
If you read at the port address + 1, then you will get an integer containing the byte of the status data.
#10
Re: How do I access interrupts in Visual Basic
Posted 22 August 2012 - 05:22 AM
TNT, on 05 February 2008 - 12:33 AM, said:
HOWEVER. .. it returns a single integer from the interrupt port
as in : Public Declare Function Inp Lib "inpout32.dll" Alias "Inp32" _
(ByVal PortAddress As Integer) As Integer
RATHER THAN, the expect type of value as follows:
Public Type RegType AX As Integer ' installed BX As Integer ' mode CX As Integer ' nActive DX As Integer BP As Integer SI As Integer DI As Integer Flags As Integer End Type Public inRegs As RegType Public outRegs As RegType Public PortNumber As String ' port being eg: &70h Public ValueFromPort As String ' hexadecimal Public ValueToPort As String
The various .AX .BX . CX etc. each contain different bits of information that are needed for a returned value from a parallel port. This InpOut32.DLL routine returns (as far as I can tell) only the one single integer.
The following code snippit shows how I'm expecting to be able to use the various items in the data type (as in this modified old DOS routine).
___________
1112 Select case iOption Case 1 1120 inRegs.AX = &H1 'turn system on Call INTERRUPT(&H70, InRegs, OutRegs) Exit Sub Case 2 1130 inRegs.AX = &H0 'turn system off Call INTERRUPT(&H70, InRegs, OutRegs) Exit Sub ' Case 3 and 4 not shown in this example) Case 5 ' do nothing Exit Sub Case 6 'DCC reset 1350 inRegs.AX = &H100 Call INTERRUPT(&H70, InRegs, OutRegs) 'f OutRegs.AX = 0 Then Print " DCC SYSTEM RESET " 'If OutRegs.AX < 0 Or OutRegs.AX > 0 Then Print " RESET UNSUCCESSFUL" 'Print " ANY KEY WILL CONTINUE FROM RESET" 1355 'A$ = INKEY$: If A$ = "" Then GoTo 1355 'CLS exit sub End select Exit Sub
__________________
(indents and leading spaces don't seem to be allowed in this post - so the above snippet is not formatted with indents for readablity - Sorry)
_________________________
I still would like to find a way to access the interrups and get back information of the 'RegType' type as described above.
There was another package that I found on the interenet that I downloaded called VBASM that had the expected data type structure, but I couldn't get it to work. Evidentally the .DLL was incompatibel or maybe I needed to'register' the .DLL (I don't know how to do that) Have you happened to have tried the VBASM code to accomplish access to interrupts in Visual Basic? That seems closer to what I need, but I can't get it to work.
Thanks for your helpful suggestion, but I'm still stuck.....
I know how to register a dll and that could be your problem! First after registering a dll if you are not using it anymore you will have to remove it from your registry. It will be listed in hkey root under the name of the dll way down the list after extensions. A good cleaner could remove it, I use free windows registry cleaner and sometimes it misses; but you have to change the path of the dll.
Now to register a dll you have to go to start menu and click on run
in the dialog box type:
regsvr32 [name of dll with extension and path]
That is all here is to it feel free to contact me for more info about interrupt looking for same thing myself for vbscript or java. Because I found some java script BASIC CODE and would like to use the interrupt for BASIC IBM to add to the code right now it runs 2405 lines before error.
#11
Re: How do I access interrupts in Visual Basic
Posted 22 August 2012 - 05:36 AM
Nayana, on 05 February 2008 - 02:58 AM, said:
If you read at the port address + 1, then you will get an integer containing the byte of the status data.
ENDED my reply to soon; you could also try a quickbasic program to access the interrupt or gwbasic and save the numerics or registry figures to a file then use vb to run that program and attach any readings in the file to your code. It sounds kind of cheesy and it is a double program but it would work. I believe the inp out commands work fine in NT. I use it for &H3C0 for the screen and in assembly the interruopts work fine I use flat assembler there for my x86 windows xp. It says that info in system info. I have no trouble using interrupts.
|
|

New Topic/Question
Reply




MultiQuote




|