Home › Forums › HTBasic Forum › HTBasic and visa32.Ddll › Reply To: HTBasic and visa32.Ddll
Hi Mr ZeRider,
Thank you very much !
It seems like everything is ok now since i put “STDCALL” at the DLL GET section as you proposed.
I’m not sure what STDCALL is about as i didn’t see that in the software DLL example. However it is mentionned in the software documentation at that page : DLL GET but i don’t realy see when to use it or not.
Here below is the code i used for getting informations from a tcpip connected instrument. It is inspired by ZeRider code in the previous post !
Best
Mathieu
!************
! Example
!**********
LONG Retour ! Status code
LONG Session ! Unique logical ID to a default Ressource Manager Session
LONG Instru ! Unique logical ID to a session
LONG Ret_count ! Represent an integer that will be set to the number of byte actually transferred (From viWrite and viRead() From “VISA Library Specification” document)
DIM Rep$[100] ! Represent the buffer to receive data from device. (From viRead() from “VISA Library Specification” document)
DIM Connex$[64]
Connex$=”TCPIP0::instrumentIPAddress::inst0::INSTR” ! Connexion parameters
DLL UNLOAD ALL
DLL LOAD “visa32”
DLL GET “STDCALL LONG VISA32:viOpenDefaultRM” AS “Vi_open_default” ! Function from VISA DLL
DLL GET “STDCALL LONG VISA32:viOpen” AS “Vi_open” ! Function from VISA DLL
DLL GET “STDCALL LONG VISA32:viClose” AS “Vi_close” ! Function from VISA DLL
DLL GET “STDCALL LONG VISA32:viWrite” AS “Vi_write” ! Function from VISA DLL
DLL GET “STDCALL LONG VISA32:viRead” AS “Vi_read” ! Function from VISA DLL
DLL GET “STDCALL LONG VISA32:viGetAttribute” AS “Vi_get_att” ! Function from VISA DLL
!———————————————————
Default: ! VI Open Default RM
!———————————————————
DISP “—> VI OPEN DEFAULT RM : In progress …”
!********************************************
Retour=-1000
Retour=FNVi_open_default(Session)
SELECT Retour
CASE 0
PRINT “> VI OPEN DEFAULT RM”
PRINT “VIsession =”;Session
CASE ELSE
Type$=”DEC”
Valeur$=VAL$(Retour)
CALL Convert(Type$,Valeur$,Dec,Hex$,Bin$)
PRINT “* VI OPEN DEFAULT RM : Retour=”;Retour
CALL List_error(Hex$)
END SELECT
!———————————————————
Viopen: ! VI Open SESSION
!———————————————————
DISP “—> VI OPEN SESSION: In progress …”
Retour=-1000
Retour=FNVi_open((Session),Connex$,0,0,Instru)
SELECT Retour
CASE 0
PRINT “> VI OPEN SESSION”
PRINT “Instru =”;Instru
CASE ELSE
Type$=”DEC”
Valeur$=VAL$(Retour)
CALL Convert(Type$,Valeur$,Dec,Hex$,Bin$)
PRINT “* VI OPEN SESSION: Retour=”;Retour
CALL List_error(Hex$)
END SELECT
!———————————————————
Viwrite: ! VI Write CMD
!———————————————————
DISP “—> VI Write CMD: In progress …”
Retour=-1000
Cmd_count=6 ! Nbr of byte to be writter
Retour=FNVi_write((Instru),”*IDN?”,6,Ret_count)
SELECT Retour
CASE 0
PRINT “> VI WRITE ”
PRINT “Instru =”;Instru
CASE ELSE
Type$=”DEC”
Valeur$=VAL$(Retour)
CALL Convert(Type$,Valeur$,Dec,Hex$,Bin$)
PRINT “* VI WRITE : Retour=”;Retour
CALL List_error(Hex$)
END SELECT
!———————————————————
Viread: ! VI Read response
!———————————————————
DISP “—> VI Read : In progress …”
Retour=-1000
Retour=FNVi_read((Instru),Rep$,100,Ret_count)
PRINT “IDN : “;Rep$
SELECT Retour
CASE 0
PRINT “> VI READ ”
PRINT “Instru =”;Instru
CASE ELSE
Type$=”DEC”
Valeur$=VAL$(Retour)
CALL Convert(Type$,Valeur$,Dec,Hex$,Bin$)
PRINT “* VI READ : Retour=”;Retour
CALL List_error(Hex$)
END SELECT
!———————————————————
Vigetattribute: ! VI Get IP Address Attribute
!———————————————————
DISP “—> VI Get IP Address attribute : In progress …”
Retour=-1000
LONG Decval=DVAL(“bfff0195”,16) ! Decimal value of VI_ATTR_TCPIP_ADDR 0xBFFF0195
Retour=FNVi_get_att((Instru),(Decval),Rep$)
PRINT “IP Address : “;Rep$
SELECT Retour
CASE 0
PRINT “> VI GET IP ADDRESSE ATTRIBUTE ”
PRINT “Instru =”;Instru
CASE ELSE
Type$=”DEC”
Valeur$=VAL$(Retour)
CALL Convert(Type$,Valeur$,Dec,Hex$,Bin$)
PRINT “* VI GET ATTRIBUTE : Retour=”;Retour
CALL List_error(Hex$)
END SELECT
!———————————————————
Viclose_instru: ! VI Close Instru
!———————————————————
DISP “—> VI CLOSE SESSION: In progress …”
Retour=-1000
Retour=FNVi_close((Instru))
SELECT Retour
CASE 0
PRINT “> VI CLOSE SESSION ”
PRINT “Instru =”;Instru
CASE ELSE
Type$=”DEC”
Valeur$=VAL$(Retour)
CALL Convert(Type$,Valeur$,Dec,Hex$,Bin$)
PRINT “* VI CLOSE SESSION : Retour=”;Retour
CALL List_error(Hex$)
END SELECT
!———————————————————
Viclose_session: ! VI Close Session
!———————————————————
DISP “—> VI CLOSE DEFAULT RM : In progress …”
Retour=-1000
Retour=FNVi_close((Session))
SELECT Retour
CASE 0
PRINT “> VI CLOSE DEFAULT RM ”
PRINT “Session =”;Session
CASE ELSE
Type$=”DEC”
Valeur$=VAL$(Retour)
CALL Convert(Type$,Valeur$,Dec,Hex$,Bin$)
PRINT “* VI VI CLOSE DEFAULT RM : Retour=”;Retour
CALL List_error(Hex$)
END SELECT
DISP “—-> All is closed ”
END
! To use this code, add the two SUBs proposed by ZeRider at the previous post