You are not logged in. You can browse in the PowerBASIC Community, but you must click Login (top right) before you can post. If this is your first visit, check out the FAQ or Sign Up.
'=============================================================================
' portest3.bas - It Works!
'-----------------------------------------------------------------------------
#COMPILE EXE
#INCLUDE "win32api.inc"
'-----------------------------------------------------------------------------
%IDsend = 1
%IDExit = 2
%IDreceive = 3
%IDenvia = 4
GLOBAL Value AS INTEGER
GLOBAL valorrecebido AS INTEGER
GLOBAL PortAddress AS INTEGER
GLOBAL F AS INTEGER
'-----------------------------------------------------------------------------
CALLBACK FUNCTION sendport()
CALL out32 (BYVAL PortAddress, BYVAL Value)
CONTROL SET TEXT CBHNDL,%IDenvia, STR$(value)
CALL in32 (BYVAL PortAddress)
CONTROL SET TEXT CBHNDL,%IDreceive, STR$(F)
Value = Value + 1
IF Value => 255 THEN Value = 0
END FUNCTION
'-----------------------------------------------------------------------------
CALLBACK FUNCTION Fim()
DIALOG END CBHNDL, 0
END FUNCTION
'-----------------------------------------------------------------------------
FUNCTION PBMAIN() AS LONG
LOCAL hDlg AS LONG
PortAddress = &H378 '(Usual PARALEL-port address IS &h378)
Value = 1 'Valor inicial a ser enviado para o Port
DIALOG NEW 0, "IN-OUT test to PORT 3F8H", ,, 200, _
100, 0, 0 TO hDlg
CONTROL ADD LABEL,hDlg,-1,"Read value ",10,10,80,8
CONTROL ADD LABEL,hDlg,-1,"Sent value ",10,30,80,8
CONTROL ADD TEXTBOX,hDlg,%IDreceive,"",90,10,60,12
CONTROL ADD TEXTBOX,hDlg,%IDenvia,"",90,30,60,12
CONTROL ADD BUTTON, hDlg, %IDsend, "Send", 50, 75, 40, 14, _
%BS_DEFAULT CALL sendport
CONTROL ADD BUTTON, hDlg, %IDEXIT, "End", 110, 75, 40, 14,0 CALL Fim
DIALOG SHOW MODAL hDlg
END FUNCTION
'-----------------------------------------------------------------------------
REM DECLARE SUB Out32(BYVAL PortAddress AS INTEGER,BYVAL ByteValue AS BYTE)
SUB Out32(BYVAL PortAddress AS INTEGER,BYVAL ByteValue AS BYTE)
' ! push dx
! mov dx,PortAddress
! mov al,Value
! out dx,al
' ! pop dx
END SUB
REM DECLARE FUNCTION In32(BYVAL PortAddress AS INTEGER) AS BYTE
FUNCTION In32(BYVAL PortAddress AS INTEGER) AS BYTE
LOCAL Valorrecebido AS BYTE
' ! push dx
! mov dx,PortAddress
! in al,dx
! mov Valorrecebido,al
' ! pop dx
F = Valorrecebido
END FUNCTION
'----------------------------------------------------------------------------
Mehmet,
In revisig my posting above, I noticed that a line of code
was devided improperly.
Please correct the line as follows:
DIALOG NEW 0, "IN-OUT test to PORT 3F8H", ,, 200, 100, 0, 0 TO hDlg
www.sstnet.com has a really nice freeware package (DLPORTIO)
that works with NT. I haven't tried it with win2000, but will oon.
You will need to get Depends.exe (Dependency Walker) to get change
the alias' in the include file. The DLL has those "C mangled"
names, so if you don't change them, nothing works.
I can't remember where I got Dependency Walker. It is free on
the web, maybe even on the PB site.
I've gotten the byte i/o routines to work just fine. They have
some buffer version, but not luck. Since it's a freebie they
would really like it if you don't bother them with tech support.
Russ Srole
------------------
"There are two novels that can change a bookish fourteen-year old's life: The Lord of the Rings and Atlas Shrugged. One is a childish fantasy that often engenders a lifelong obsession with its unbelievable heroes, leading to an emotionally stunted, socially crippled adulthood, unable to deal with the real world. The other, of course, involves orcs." - John Rogers
Be prepared! Someday soon MicroSoft won't be selling a version of
windows that allows the direct port access.
------------------
"There are two novels that can change a bookish fourteen-year old's life: The Lord of the Rings and Atlas Shrugged. One is a childish fantasy that often engenders a lifelong obsession with its unbelievable heroes, leading to an emotionally stunted, socially crippled adulthood, unable to deal with the real world. The other, of course, involves orcs." - John Rogers
We process personal data about users of our site, through the use of cookies and other technologies, to deliver our services, and to analyze site activity. For additional details, refer to our Privacy Policy.
By clicking "I AGREE" below, you agree to our Privacy Policy and our personal data processing and cookie practices as described therein. You also acknowledge that this forum may be hosted outside your country and you consent to the collection, storage, and processing of your data in the country where this forum is hosted.
Comment