Hey all,
I was working recently with a customer that was having some exceptions thrown due to utilizing the “.ToText” function to convert a string to Text format. One of the things my software does is connect to some specific devices on the local network and it reads information from them like firmware version, etc. The firmware version is always of the format A6.5.5 or something like that. So why that would cause an exception in the .ToText function was a mystery to me. So I put some Try/Catch blocks in the code and had the software email me whenever the exception occurs and provide me with what is in the “FirmwareVersion” property that is causing this issue. What I got back jut doesn’t make sense and I can’t see how it could possibly happen.
There is one single place in my code where I update a FirmwareVersion property of the device being read. It’s in a method, triggered by a timer from a TCPSocket. I parse the data with regular expressions looking for patters like Firmware Version, serial port baud rates, and other device info. Here is the code I use to look for the firmware version:
rx.SearchPattern = "(?msi-U)^([A-Z]\\x20?(?:\\d+\\.){1,2}\\d*\\x20?[A-Za-z]*.*)\\R+
```
"
match = rx.Search(MySockData)
If match <> Nil Then
FirmwareVersion = match.SubExpressionString(1)
Dim fw() As String = FirmwareVersion.Split(EndOfLine)
FirmwareVersion = fw(0)
FirmwareVersion = Trim(FirmwareVersion)
End If
Now, if you look at the code, whatever is picked up by the regex is then dumped into a If/Then block which splits any possible data received and you should end up with a one line string that has been trimmed of any white space. I don’t see how you could get anything else.
But this is what is being reported back to me by the app at the customer:
A6.4.12
```
<!-- Screen Capture
----------------------------------------------------------------------------------->
<fieldset>
<legend style="font-weight:bold;">Unnamed 2G Transmitter - Image Pull ™</legend>
<img src="pull.bmp" width=320px height=180px style="margin:auto;display:block;"></img>
<br />
<button style="margin:auto;display:block;" onClick="window.location.reload(true)">Refresh</button>
</fieldset>/usr/local/bin # astparam dump
CRC = 0xF4926749
default_gateway=192.168.200.25
web_ui_cfg=nevwaus
pull_on_boot=n
soip_type2=y
soip_guest_on=y
hdcp_always_on=y
no_usb=n
en_video_wall=y
seamless_switch=y
edid_rom_mode=HDMI
ip_mode=static
ipaddr=192.168.30.26
netmask=255.255.255.0
gatewayip=192.168.30.25
/usr/local/bin # astparam r soip_guest_on
n/usr/local/bin # astparam r soip_type2
y/usr/local/bin # astparam g soip_guest_on
-snip-
There’s actually a whole lot more that I’ve cut out.
When I use Kem’s RegExRX to test this, the expression works fine and I get the A6.4.12 back as SubExpression #1. But even if I got more than that, there’s a gazillion line endings in this so why would the code in the text block not give me just the first line? It seems 100% impossible. And there is nowhere else in code where this FirmwareVersion property gets set. Nowhere.
And I’ve only had this reported from this one customer.
App was compiled with Xojo 2017R3.1 and is running on Windows 7 in 64 bit.
And this doesn’t happen all the time. Only randomly it seems. I’ll get a bunch of emails all at once.