Hey all,
I’m having an odd NOE error show up in my app when running a specific process off a timer. To make it simple, I have a button control that is stored in a Dictionary that gets virtually pushed when the user schedules it. The button push sends a command via a TCP socket to a device. This device is an object in Xojo. Everything seems to run flawlessly in OS X but not so in Windows it seems. Bear with all my code posting here as I tied it together at the end…
When setting up the TCP connection to the device, I set up a handler for an event that is raised by the device object when the TCP socket connected event is raised. When the code finishes executing, the handler is removed. Here is how I am setting things up. It says Serial port because it is basically an IP-serial device.
Public Function ConnectToSerialPort() as Boolean
If RS232Mode = "Guest Mode" Then // We only send commands when the device is in a certain mode
System.DebugLog "Attempting to connect to the RS232 Port of Device "+me.MyName
// Add the handler
Try
AddHandler SerialPortSocket.Connected, WeakAddressOf SerialPortSocketConnected
Catch
End Try
// Set up the socket
SerialPortSocket.Port = 6752
SerialPortSocket.Address = IPAddress
SerialPortSocket.NetworkInterface = SelectedNIC
SerialPortSocket.Connect
Else
Return False
End If
End Function
The connected event handler of the socket - the method SerialPortSocketConnected looks like this:
Public Sub SerialPortSocketConnected(t as TCPSocket)
// Trying to discover the NOE
If t = Nil Then Break
If me = Nil Then Break
System.DebugLog "In SerialPortSocketConnected Event for Device "+me.MyName
RaiseEvent Connected6752
End Sub
The event Conected6752 is the event that gets the handler added and removed in the action event of the pushbutton. Here is some of that code:
If Me.DevicePort = 6752 And Not Me.SendToAV Then
System.DebugLog "Need to send command to Device RS232 for ButtonID "+str(me.ButtonID)
Try
AddHandler j.Connected6752, WeakAddressOf SendDevRS232 // j is my device with the socket
Catch
End Try
System.DebugLog "Sending RS232 command "+CommandCode+" to Device "+j.MyName+" From RemoteButton "+str(ButtonID)
SendDevRS232(j)
The SendDevRS232 method (which is also the handler for the device’s Connected6752 event then looks like:
Public Sub SendDevRS232(optional j as JDevice)
If Not j.SerialPortSocket.IsConnected Then
Call j.ConnectToSerialPort
System.DebugLog "Not Connected to Device Serial Port for JDevice "+j.MyName+" Connecting To it Now."
Return
End If
System.DebugLog "Connected to Device Serial Port for JDevice "+j.MyName+" Going to Send Commands."
// Get the commands from the dictionary
Dim Commands() As String
Dim DelayValue() As Integer
Dim d As Dictionary = SetUpCommandTiming
Commands = d.Value("Commands")
DelayValue = d.Value("DelayValue")
Dim TotalDelay As Integer = 0
If DelayValue.Ubound <> Commands.Ubound Then
Break
End If
// We might have multiple commands with a delay between commands. So loop it and calculate the delay
For i As Integer = 0 To Commands.Ubound
System.DebugLog "Sending Commands to the RS232 Port of Device "+j.MyName+" Command is "+commands(i)
TotalDelay = TotalDelay+DelayValue(i)
System.DebugLog "Delay value for command timer for Device "+j.MyName+" is "+str(TotalDelay)
If TotalDelay < 0 Then TotalDelay = 0
// Send the command to the socket after the delay
Xojo.Core.Timer.CallLater(TotalDelay, AddressOf j.SendRS232Command, commands(i).ConvertHexStringToAscii)
Next
// Remove the handler
RemoveHandler j.Connected6752, WeakAddressOf SendDevRS232
End Sub
I’ve posted all of this to then ask how odd it is that I get error stacks like this for this Odd NOE exception. Here is some of the stack trace:
RuntimeRaiseException
RaiseNilObjectException
Delegate.IM_Invoke%%<SegmentedControl>
AddHandler.Stub.29%%
JDevice.SerialPortSocketConnected%%o<JDevice>o<TCPSocket>
Delegate.IM_Invoke%%<Segm
That’s all I have as the message box that I have pop up in my app doesn’t show more than that and I have these logged but it appears my client’s computer is not allowing the log files to be saved or is saving them someplace other than where I expect them.
Here’s a second one:
RuntimeRaiseException
RaiseNilObjectException
Delegate.IM_Invoke%%<ComboBox>
AddHandler.Stub.29%%
JDevice.SerialPortSocketConnected%%o<JDevice>o<TCPSocket>
Delegate.IM_Invoke%%<ComboBox>
OK. First one happens with a Segmented Control. The second with a combo box. But what I don’t understand is NOWHERE in my code am I doing ANYTHING with segmented control or a combobox when running this code. Yes, I have one Segmented Control in my app and I have a couple of ComboBoxes, but they have nothing to do with this control or with anything in the underlying code I am using. I am stumped as to what is going on. So I figured I would ask for some help here…
Anyone???