Sign in to follow this  
Followers 0
diveboy

1wire interface ?

5 posts in this topic

has anyone done any 1wire development with autoit ?

or suggested reading for accessing it via com interface ?

Thanks in advance

Michael.

Share this post


Link to post
Share on other sites



has anyone done any 1wire development with autoit ?

or suggested reading for accessing it via com interface ?

Thanks in advance

Michael.

AutoIt can use a COM interface, or DLL. The question is from where? What the provider of the interface? What driver/software are you loading in widows for the 1-Wire device? Their BBS site lists at least one article on software, but it's a broken link now.

So, what are you using for software access to the device?

<_<


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

AutoIt can use a COM interface, or DLL. The question is from where? What the provider of the interface? What driver/software are you loading in widows for the 1-Wire device? Their BBS site lists at least one article on software, but it's a broken link now.

So, what are you using for software access to the device?

<_<

Sorry for the delay.

there are two interfaces but one has been mothballed, so it's tmex interface, which is IBFS32.DLL

They have some vb 6 source code examples to use it, so how do I do the same in autoit ? this is part of the example vb6 project that came with the SDK.

' External DLL function declarations

'// Session Layer functions
Declare Function TMExtendedStartSession Lib "IBFS32.DLL" (ByVal PortNum As Integer, ByVal PortType As Integer, ByVal Reserved As Any) As Long
Declare Function TMValidSession Lib "IBFS32.DLL" (ByVal session_handle As Long) As Integer
Declare Function TMEndSession Lib "IBFS32.DLL" (ByVal session_handle As Long) As Integer

'// File Operations Layer functions
Declare Function TMFirstFile Lib "IBFS32.DLL" (ByVal session_handle As Long, state_buffer As Byte, fentry As Byte) As Integer
Declare Function TMNextFile Lib "IBFS32.DLL" (ByVal session_handle As Long, state_buffer As Byte, fentry As Byte) As Integer
Declare Function TMOpenFile Lib "IBFS32.DLL" (ByVal session_handle As Long, state_buffer As Byte, fentry As Byte) As Integer

Share this post


Link to post
Share on other sites

The function declarations help, but we need to see how they are used. Isn't there an example of actual usage of these functions?

Are you getting this stuff from iButton: 1-Wire SDK for Windows, or somewhere else that can be downloaded or looked at online for free?

<_<


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

yup, from the SDK downloadable from that page. 4.00beta

This is part of the VB example for the TMEX interface, if you install the sdk, Examples\TMEX\VBasic\RayVB32

Sub ReplaceFile()
    Dim flag, I, J, hndl, ln, rslt  As Integer
    Dim mln As Integer
    Dim Epr As Integer
    Dim ans As Integer
    Dim Buf(7140) As Byte
    
    '// result flag
    rslt = False
    Epr = False

    '// start a session
    SHandle = TMExtendedStartSession(PortNum, PortType, vbNullString)

    '// if SHandle valid then try to read the file to edit
    If (SHandle > 0) Then
        '// set the selected rom
        flag = TMRom(SHandle, state_buffer(0), SelectROM(0))
        '// first change the directory to the correct current directory
        '// need to do this because background task of listing roms has
        '// reset the current directory
        flag = TMChangeDirectory(SHandle, state_buffer(0), 0, DirBuf(0))

        '// check for an program job
        flag = TMCreateProgramJob(SHandle, state_buffer(0))
        If (flag = 1) Then Epr = True

        '// delete the existing file
        flag = TMDeleteFile(SHandle, state_buffer(0), SelectFile(0))
        If ((flag = 1) Or (flag = -6)) Then
            '// success or delete of file already deleted
            '// create the file to write
            hndl = TMCreateFile(SHandle, state_buffer(0), mln, SelectFile(0))
            If (hndl >= 0) Then
                '// success in create
                ln = Len(FileData.EditData.Text)
                For I = 1 To ln
                    Buf(I - 1) = Asc(Mid$(FileData.EditData.Text, I, 1))
                Next I
                flag = TMWriteFile(SHandle, state_buffer(0), hndl, Buf(0), ln)
                If (flag = ln) Then
                    '// success with write
                    FileData.Hide
                    rslt = True
                End If
            End If
        End If

        '// check to see if need to finish program job
        If (Epr = True And rslt = True) Then
            '// loop trying to write the device
            '// until done or a user abort
            Do
                flag = TMDoProgramJob(SHandle, state_buffer(0))
                If (flag < 0) Then
                    If (flag = -22) Then
                        ans = MsgBox("Device is written such that updating is impossible.", 53, "RAYVB")
                    ElseIf (flag = -23) Then
                        ans = MsgBox("Program device can not be written with non-program devices on the 1-Wire.", 53, "RAYVB")
                    ElseIf (flag = -1) Then
                        ans = MsgBox("Device not found, replace and press retry!", 53, "RAYVB")
                    ElseIf (flag = -200) Then
                        SHandle = TMExtendedStartSession(PortNum, PortType, vbNullString)
                    ElseIf (flag = -13) Then
                        ans = MsgBox("Can not be program with this hardware or software configuration!", 53, "RAYVB")
                    Else
                        ans = MsgBox("Unknown error! " + Str$(flag), 53, "RAYVB")
                    End If
        
                    '// check result of message box
                    If (ans = 2) Then  '// Cancel
                        rslt = False
                        '// reset the program job
                        flag = TMCreateProgramJob(SHandle, state_buffer(0))
                        Exit Do
                    End If
                End If
            Loop Until (flag = 1)
        End If

        '// end the session
        flag = TMEndSession(SHandle)
    End If

    '// check result flag
    If (Not rslt) Then
        MsgBox "Could not write data file", 16, "RAYVB"
    End If
End Sub

I've attached the main .bas file from their vb 6 project and also their tmex declarations

Thanks again for your time.

Michael.

Edited by diveboy

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0