Convert code to FWH

Convert code to FWH

Postby cdmmaui » Fri Apr 28, 2023 9:26 pm

Happy Friday Everyone,

Could someone help me convert this code to FWH? I would happy to pay you for your time.

Thank you!

#define AddrPort 0x2e
#define DataPort 0x2f
#define SIO_UnLock_Value 0x87
#define SIO_Lock_Value 0xaa
#define SIO_LDN_GPIO 0x07
#define GPIO_Port 0xF1

// Enter_Config
WriteByte (AddrPort , SIO_UnLock_Value);
WriteByte (AddrPort , SIO_UnLock_Value);

WriteByte (AddrPort , 0x07);
WriteByte (DataPort , SIO_LDN_GPIO);

//Set OUT1~OUT8Value
WriteByte( AddrPort , GPIO_Port);
WriteByte (DataPort , 0x00); //set OUT1~OUT8 value, OUT1=Bit0, OUT2=Bit1

// Read In1~In8 value
WriteByte( AddrPort, 0xED);
Data=ReadByte DataPort ); //Read In1~In8 value

// close config mode
WriteByte( AddrPort , SIO_Lock_Value);
*~*~*~*~*~*~*~*~*~*
Darrell Ortiz
CDM Software Solutions, Inc.
https://www.cdmsoft.com
User avatar
cdmmaui
 
Posts: 689
Joined: Fri Oct 28, 2005 9:53 am
Location: Houston ∙ Chicago ∙ Los Angeles ∙ Miami ∙ London ∙ Hong Kong

Re: Convert code to FWH

Postby Antonio Linares » Sat Apr 29, 2023 4:29 am

Dear Darrell,

What C compiler are you using ?

Are you using 32 or 64 bits ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41315
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Convert code to FWH

Postby cdmmaui » Sat Apr 29, 2023 4:31 am

Hi Antonio,

Borland
*~*~*~*~*~*~*~*~*~*
Darrell Ortiz
CDM Software Solutions, Inc.
https://www.cdmsoft.com
User avatar
cdmmaui
 
Posts: 689
Joined: Fri Oct 28, 2005 9:53 am
Location: Houston ∙ Chicago ∙ Los Angeles ∙ Miami ∙ London ∙ Hong Kong

Re: Convert code to FWH

Postby Antonio Linares » Sat Apr 29, 2023 4:36 am

32 bits ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41315
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Convert code to FWH

Postby cdmmaui » Sat Apr 29, 2023 4:42 am

Hi Antonio,

Yes
*~*~*~*~*~*~*~*~*~*
Darrell Ortiz
CDM Software Solutions, Inc.
https://www.cdmsoft.com
User avatar
cdmmaui
 
Posts: 689
Joined: Fri Oct 28, 2005 9:53 am
Location: Houston ∙ Chicago ∙ Los Angeles ∙ Miami ∙ London ∙ Hong Kong

Re: Convert code to FWH

Postby Antonio Linares » Sat Apr 29, 2023 5:11 am

Dear Darrell,

Please download this zip file:
https://github.com/starofrainnight/winio/releases/download/3.0/WinIo.zip

And try this initial version:
Code: Select all  Expand view
#include "FiveWin.ch"
#include "dll.ch"

#define AddrPort 0x2e
#define DataPort 0x2f
#define SIO_UnLock_Value 0x87
#define SIO_Lock_Value 0xaa
#define SIO_LDN_GPIO 0x07
#define GPIO_Port 0xF1

static hDll

function Main()

   local Data

   hDLL = LoadLibrary( "winio.dll" )

   InitializeWinIO()

   // Enter_Config
   WriteByte (AddrPort , SIO_UnLock_Value)
   WriteByte (AddrPort , SIO_UnLock_Value)

   WriteByte (AddrPort , 0x07)
   WriteByte (DataPort , SIO_LDN_GPIO)

   //Set OUT1~OUT8Value
   WriteByte( AddrPort , GPIO_Port)
   WriteByte (DataPort , 0x00) //set OUT1~OUT8 value, OUT1=Bit0, OUT2=Bit1

   // Read In1~In8 value
   WriteByte( AddrPort, 0xED)
   Data=ReadByte( DataPort ) //Read In1~In8 value

   // close config mode
   WriteByte( AddrPort , SIO_Lock_Value)

   ShutDownWinIo()
   FreeLibrary( hDLL )

   MsgInfo( "ok" )

return nil

DLL FUNCTION InitializeWinIO() AS BOOL FROM "InitializeWinIo" LIB hDLL
DLL FUNCTION WriteByte( nPort AS _INT, nValue AS _INT ) AS BOOL FROM "SetPortVal" LIB hDLL
DLL FUNCTION ReadByte( nPort AS _INT ) AS _INT FROM "GetPortVal" LIB hDLL
DLL FUNCTION ShutdownWinIo() AS VOID FROM "ShutdownWinIo" LIB hDLL
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41315
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Convert code to FWH

Postby Antonio Linares » Sat Apr 29, 2023 5:17 am

Please replace this line:

InitializeWinIO()

with:

MsgInfo( InitializeWinIO() )

to check if the DLL properly initializes
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41315
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Convert code to FWH

Postby Antonio Linares » Sat Apr 29, 2023 5:19 am

After running it please check if there is a hb_out.log file
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41315
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Convert code to FWH

Postby Antonio Linares » Sat Apr 29, 2023 5:32 am

There is something else to implement, doing it...
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41315
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Convert code to FWH

Postby Antonio Linares » Sat Apr 29, 2023 5:41 am

regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41315
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Convert code to FWH

Postby Antonio Linares » Sat Apr 29, 2023 5:57 am

This should be the right code:

winio32.dll and winio32.sys should be where your EXE is placed.

ports.prg
Code: Select all  Expand view
#include "FiveWin.ch"
#include "dll.ch"

#define AddrPort 0x2e
#define DataPort 0x2f
#define SIO_UnLock_Value 0x87
#define SIO_Lock_Value 0xaa
#define SIO_LDN_GPIO 0x07
#define GPIO_Port 0xF1

static hDll

function Main()

   local Data

   hDLL = LoadLibrary( "winio32.dll" )

   MsgInfo( hDLL )

   MsgInfo( InstallWinIoDriver( "WinIo32.sys", .T. ) )

   MsgInfo( InitializeWinIO() )

   // Enter_Config
   WriteByte (AddrPort , SIO_UnLock_Value)
   WriteByte (AddrPort , SIO_UnLock_Value)

   WriteByte (AddrPort , 0x07)
   WriteByte (DataPort , SIO_LDN_GPIO)

   //Set OUT1~OUT8Value
   WriteByte( AddrPort , GPIO_Port)
   WriteByte (DataPort , 0x00) //set OUT1~OUT8 value, OUT1=Bit0, OUT2=Bit1

   // Read In1~In8 value
   WriteByte( AddrPort, 0xED)
   Data=ReadByte( DataPort ) //Read In1~In8 value

   // close config mode
   WriteByte( AddrPort , SIO_Lock_Value)

   ShutDownWinIo()
   FreeLibrary( hDLL )

   MsgInfo( "ok" )

return nil

DLL FUNCTION InstallWinIoDriver( cPath AS LPSTR, lIsDemandLoaded AS BOOL ) AS BOOL FROM "InitializeWinIo" LIB hDLL
DLL FUNCTION InitializeWinIO() AS BOOL FROM "InitializeWinIo" LIB hDLL
DLL FUNCTION WriteByte( nPort AS _INT, nValue AS _INT ) AS BOOL FROM "SetPortVal" LIB hDLL
DLL FUNCTION ReadByte( nPort AS _INT ) AS _INT FROM "GetPortVal" LIB hDLL
DLL FUNCTION ShutdownWinIo() AS VOID FROM "ShutdownWinIo" LIB hDLL
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41315
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Convert code to FWH

Postby Antonio Linares » Sat Apr 29, 2023 6:03 am

A brief explanation:

A Windows app can't directly manage the ports for security reasons, it must use a driver.

WinIO32.sys is the driver and WinIO32.DLL is the DLL to manage such driver

This WinIO was developed by http://www.sysinternals.com but lately was bought by Microsoft and they dropped it.

Thats why this free github repo has implemented it: https://github.com/starofrainnight/winio
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41315
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Convert code to FWH

Postby cdmmaui » Sat Apr 29, 2023 12:18 pm

Hello Antonio,

Thank you so much! Initially we are looking to read certain values to determine status of a device, simply 0 or 1 (on or off).

Thank you again!
*~*~*~*~*~*~*~*~*~*
Darrell Ortiz
CDM Software Solutions, Inc.
https://www.cdmsoft.com
User avatar
cdmmaui
 
Posts: 689
Joined: Fri Oct 28, 2005 9:53 am
Location: Houston ∙ Chicago ∙ Los Angeles ∙ Miami ∙ London ∙ Hong Kong

Re: Convert code to FWH

Postby Jimmy » Sun Apr 30, 2023 9:13 pm

hi,

i like to know what Hardware do you use with this CODE :?:
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1586
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: Convert code to FWH

Postby cdmmaui » Sun Apr 30, 2023 10:14 pm

Hi Jimmy,

Nuvoton NCT6106D. We are looking to get status from specific pin, either on (1) or off (0).
*~*~*~*~*~*~*~*~*~*
Darrell Ortiz
CDM Software Solutions, Inc.
https://www.cdmsoft.com
User avatar
cdmmaui
 
Posts: 689
Joined: Fri Oct 28, 2005 9:53 am
Location: Houston ∙ Chicago ∙ Los Angeles ∙ Miami ∙ London ∙ Hong Kong

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Otto and 85 guests