Parallel Programming #5

Blitz3D Forums/Blitz3D Beginners Area/Parallel Programming #5

Thanks again to soja and now Arbitrage!

Did you mean for me to read the BASIC tutorials with Blitz3D entitled types1.bb and types2.bb for the documentation on (custom) types?

Anyway, I made the following changes:
1. moved Type definition outside of the loop (all of it, I think.);
2. sorry about showing * with GetPortVal -- I had already changed it to % when I saw it did not work, but I sent you an older version of the .decls file;
3. term definition:
A) ...analogous to structs in C... Does that mean constructs?
B) OK, now I know that the WinIo documentation is expressing C language (You mentioned that BB int% is equated to Bool in C.), but what is the "Bank thing"? Is it another way to reference custom typing?

So... where am I at? The program again runs but the results are embedded in the past -- all the loop (still) returns me is a value of 0! Help again! Following is the updated versions:


.lib "winio.dll"


;Initializes the WinIo library (boolean).  Does not have to be used with Windows XP.
InitializeWinIo%():"InitializeWinIo"

;Performs shutdown of the WinIo library.  Must be called before terminiating an application or when no longer using the WinIo library.
ShutdownWinIo():"ShutdownWinIo"

;Calls the WinIo driver (boolean).  Parameters: (Points to a null-terminated string to specify the winio.sys driver path, Set to false).
InstallWinIoDriver%(WinIoDriverPath$, IsDemandLoaded):"InstallWinIoDriver"

;Removes the WinIo driver (boolean).  
RemoveWinIoDriver%():"RemoveWinIoDriver"

;Reads a 1, 2, or 4 byte value from specifies I/O port (pointer).  Parameters: (Input port $379, DWORD variable, BYTE = 1).  
GetPortVal%(PortAddr, PortVal, Size):"GetPortVal"

;Writes a 1, 2, or 4 byte value to an I/O port (boolean).  Parameters: (Output port $378, Hex value written to port, BYTE = 1).
SetPortVal%(PortAddr, PortVal, Size):"SetPortVal"



and...



;The BlitzBASIC code for:
;Direct Port access from BlitzBASIC using WinIo.

;Set graphics mode.
Graphics 800, 600, 16, 2
SetBuffer BackBuffer()

;Initializes the WinIo library.
;InitializeWinIo()

;Call the WinIo driver
If Not InstallWinIoDriver(".", False) Then
	Print "Initialization failed."
	End
EndIf

;Create Custom Type.
Type PortVal
	Field val
End Type
p.PortVal = New PortVal
DebugLog p\val

Repeat

;Read a 1 byte value from the specified port and place in variable DWORD.
GetPortVal($379, PortVal, 1)

;Print variable p
Print PortVal

Until KeyDown(1)

;Removes the WinIo driver.
RemoveWinIoDriver()

;Shutsdown the WinIo library.
;ShutdownWinIo()

End



Whenever this is over I am going to create a tutorial for beginners on using WinIo for simple parallel port operations... The next project is the serial buss. Why? Because it is a universal method (educational-wise) of controlling training robotic equipment.

Thanks, again!