Skip to main content
Submitted by dickkeane on Sat, 07/30/2016 - 09:27

I’m using VB2013 for use in a new custom application which communicates to DMC-4050 controller. I’ve downloaded most recent firmware version 1.2d to controller and I’m using gclib version 140.149.300 which I think is the latest and greatest API from Galil. Can you confirm this? I still find many references to GalilTools and GalilWidgets, but my understanding is that gclib is the most recent API which is recommended to be used for new applications.

The example gclib.vb program available on your website was very helpful to get me started. It enabled me to get to the point where I can call most of the functions that I need. I’ve already created a terminal program to send commands and handle responses. I’ve also used background worker threads for unsolicited messages and event interrupts. I’m now at the point where I want to extract some information out of the data record, which is where I’m hitting a problem. The info which I need is merely encoder position of specific motor. I expected the function call to have parameters similar to the QR command such that I could specify the block of interest, but it seems that GRecord will always read the entire data record. That’s fine since I’ll just break it down to what I need, but still I wonder how much time is wasted reading more info that I need. Anyway, I chose to do synchronous read rather asynchronous running on a separate thread. My connection string to gclib can be seen in first screenshot below. My test sub is shown in second screenshot, where at this point I’m just attempting to display the length of the data record being read. I get a mystery exception during my read attempt. I cannot find any information to decipher the exception “data was not waiting for zero-timeout read”. I’ve already attempted setting zero timeout prior to read and returning to initial timeout after the read, but it makes no difference. I think I’ll be able to continue progress if I can just get a returned byte array from my read. Any help would be appreciated.

1st screenshot....
Public Sub New(ByVal nodename As String, ByVal nodeipv4 As String)
InitializeComponent() 'first line required by visual studio designer (virus detection s/w may disable Galil driver)
Dim hdr, msg As String
_name = nodename
_ipv4 = nodeipv4
commport = 1000 'not required for Galil
galilwrapper = New Gclib() 'contains path to galil dll's
Try 'x86 platform seems to work
galilwrapper.GOpen(_ipv4 & " -d -s MG -s EI -s DR") 'direct w/o gcaps, subscribe to messages & interrupts & data records
'galilwrapper.GOpen(_ipv4 & " -d -s MG -s EI") 'direct w/o gcaps, subscribe to messages & interrupts but not data records
Catch ex As Exception 'x64 and AnyCPU platforms seem to throw exception
hdr = "Error"
msg = "Problem connecting to Galil."
MessageBox.Show(msg, hdr)
galilwrapper = Nothing
Exit Sub
End Try
ReadMAC() 'could also have pulled MAC from Nodes collection via SendARP in NetworkHardware class
ReadAxisCount() 'in preparation for axis dropdown creation
BuildAxisDropDown() 'AxisA thru AxisH for 8-axis controller
maxmsg = 5000 'prevents unsolicited message list from using excessive memory
thdMG.RunWorkerAsync() 'launches thdMG_DoWork for GalilN unsolicited messages
thdEI.RunWorkerAsync() 'launches thdEI_DoWork for GalilN event interrupts
'thdDR.RunWorkerAsync() 'launches thdDR_DoWork for data records (e.g. encoder positions)
End Sub

2nd screenshot....
Private Sub mnuTestDataRecord_Click(sender As Object, e As EventArgs) Handles mnuTestDataRecord.Click
Dim def, hdr, msg, rep As String
Dim dr() As Byte
Dim GalilN As Galil
hdr = "Input Box"
def = "Galil3"
msg = "Enter Galil node of interest <" & def & ">"
rep = InputBox(msg, hdr, def)
If Galils.Contains(rep) Then
GalilN = Galils.Item(rep) 'chosen Galil node from collection of Galil nodes
Else
hdr = "Error"
msg = rep & " does not exist."
MessageBox.Show(msg, hdr)
Exit Sub
End If
dr = GalilN.galilwrapper.GRecord(False) 'false for synch QR as opposed to async DR
hdr = "TestDataRecord"
msg = "Data record length is " & dr.Length.ToString & " bytes." 'should be 513 bytes
MessageBox.Show(msg, hdr) 'for now just evidence of successful read
dr = Nothing
GalilN = Nothing
End Sub

Comments 1

AndrewS on 08/31/2016 - 09:07

Hi dickkeane,
This is more of a specific issue that would be better and faster solved over direct communication. Can you email support@galil.com the screenshots and include 'attn: Andrew'.

Regards,
Andrew