Page 1 of 1

Phidget 1055 code issues

Posted: Thu Feb 28, 2019 8:07 pm
by crwk78
Hi,

Bear with me as I'm new to this! I've just got a 1055 Phidget IR.
I'm trying to attach it but my code doesn't seem to work and the attaching doesn't happen. Can anybody see where I'm going wrong? Also, is the code in the sendcode sub correct for a simple transmit operation, specifically is the hex code contained in a string the correct format?

Thanks for looking.

Imports Phidget22
Imports Phidget22.Events


Public Class Form1

Dim PhidgetIR As Phidget22.IR
Dim CodeInfo As Phidget22.IRCodeInfo



Private Sub Form1_Load(sender As Object, e As EventArgs) Handles
MyBase.Load

phidgettimer.Start()

End Sub


Private Sub phidgettimer_Tick(sender As Object, e As EventArgs)
Handles phidgettimer.Tick

timerlabel.Text = Integer.Parse(timerlabel.Text) + 1


PhidgetIR = New Phidget22.IR()
PhidgetIR.Open()


' doesn't go beyond this point

If PhidgetIR.Attached Then
connectedlabel.BackColor = Color.DarkGreen 'starts off red
connectedlabel.Text = "CONNECTED" 'starts off saying disconnected
phidgettimer.Stop()
SendCode()
End If


End Sub



Private Sub SendCode()

CodeInfo.BitCount = 12
CodeInfo.Length = 2
CodeInfo.Encoding = 3
CodeInfo.Gap = 44563
'CodeInfo.Trail = 0
CodeInfo.Zero = {548, 640}
CodeInfo.One = {1139, 640}
CodeInfo.Header = {2356, 640}
'CodeInfo.Repeat = {9000, 2253, 555}
'CodeInfo.ToggleMask = 0

PhidgetIR.Transmit("0x0290", CodeInfo)

End Sub


End Class

Re: Phidget 1055 code issues

Posted: Fri Mar 01, 2019 3:08 pm
by jdecoux
It looks like your code isn't waiting for the 1055 to be attached after it's opened.

Opening and attachment for Phidgets are separate steps of a Phidget program, where opening the Phidget has your program start looking for that Phidget, and the Phidget is attached once it is found and linked to your program.


If you put a parameter in the open call (e.g. PhidgetIR.Open(5000) ), your code will wait for the IR Phidget to be attached before proceeding.


For the transmit call, you can omit the "0x" part of your code string.

Re: Phidget 1055 code issues

Posted: Wed Mar 06, 2019 6:00 pm
by crwk78
Thanks jdecoux, it connects without an issue now.

I'm running to an error in the final line of code (in red) and not sure what's causing it. The error is:

"An unhandled exception of type 'System.AccessViolationException' occurred in Phidget22.NET.dll"

Any ideas?

Thanks,

Charlie K

Imports Phidget22
Imports Phidget22.Events


Public Class Form1

Dim PhidgetIR As Phidget22.IR
Dim CodeInfo As Phidget22.IRCodeInfo



Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

phidgetTimer.Start()

End Sub


Private Sub phidgetTimer_Tick(sender As Object, e As EventArgs) Handles phidgetTimer.Tick

phidgetTimerLabel.Text = Integer.Parse(phidgetTimerLabel.Text) + 1

Try
PhidgetIR = New Phidget22.IR()
PhidgetIR.Open(1000)
Catch
End Try

If PhidgetIR.Attached Then
connectedlabel.BackColor = Color.DarkGreen
connectedlabel.Text = "CONNECTED"
phidgetTimer.Stop()
phidgetTimerLabel.Text = 0
mainTimer.Start()
End If


End Sub

Private Sub mainTimer_Tick(sender As Object, e As EventArgs) Handles mainTimer.Tick

mainTimerLabel.Text = Integer.Parse(mainTimerLabel.Text) + 1

If Not PhidgetIR.Attached Then
PhidgetIR.Close()
connectedlabel.BackColor = Color.Red
connectedlabel.Text = "DISCONNECTED"
mainTimer.Stop()
mainTimerLabel.Text = 0
phidgetTimer.Start()

End If


mainTimer.Stop() 'temporary line to stop code being sent every second whilst testing
SendCode()

End Sub

Private Sub SendCode()

CodeInfo.BitCount = 48
CodeInfo.Length = 2
CodeInfo.Encoding = 2
CodeInfo.Gap = 132821
CodeInfo.Trail = 373
CodeInfo.Zero = {373, 465}
CodeInfo.One = {373, 1311}
CodeInfo.Header = {3328, 1712}
'CodeInfo.Repeat = {9000, 2253, 555}
'CodeInfo.ToggleMask = 0

PhidgetIR.Transmit("2a4c0e8d0083", CodeInfo)

End Sub



End Class

Re: Phidget 1055 code issues

Posted: Thu Mar 21, 2019 1:47 pm
by Patrick
This bug is fixed for the next release