64-bit different behaviour from 32-bit

Disclaimer: I’m using release 2015 release 4.1, not having yet achieved (domestic) management approval for 2016 release 3.

Background:
I have an existing app (on MAS, but also running here in site) which is reading environmental data and using it. It also generates a transfer file with readings and other information which is used by any remote instance of the app (eg here in the office) to recreate the displays, alerts etc. The format of the transfer file is common to a similar Windows app with which mine can inter-operate. The author of the Windows app is responsible for the transfer file format.

Up until now I have only used 32-bit compilation.

Detail:
The transfer file has a length of 613 bytes, which is an odd number because it includes 2 single character strings and the final byte, which is a boolean.

Problem:
When I make a 64-bit version of the app, the boolean is misread, becoming false instead of true (in this case). Expressed in bytes, the actual value in the file (written by the 32-bit production version, which maintains compatibility with the Windows app) is &h01. The 64-bit app reads this as &h00 (I’m printing out the byte value). And of course considers it false.

This is clearly an error – the byte is being read wrongly, and I don’t have the freedom to change the file format. Even writing and reading it as a byte doesn’t help as the read value is wrong (&h00 instead of &h01).

Is this fixed in 2016 release 3?

cheers,
Richard

Can you post the code showing the read?

Here’s the key part. There are some error trapping bits later

[code] // check that the transfer file exists, since attempting to open a non-exisiting file may create one
if not CloudWatcher.TransferFolderItem.Exists then
return Transfer.DoesNotExist
end if

// so, the transfer file exists.
// Now try to open it, recognising that if the Master is writing it, it will be flagged as in use
// If so, wait 200 ms and try again.
// Allow this 15 times.
dim DataStream as BinaryStream
dim input as Data_Transfer

DataStream = BinaryStream.Open(CloudWatcher.TransferFolderItem, False) // read-only
// handle the case of errors by an exception lock which simply reports the fact,
// then the wait and attempt to reopen will be done in the calling function.

DataStream.LittleEndian = True

// read entire binary file into structure using the stringvalue.
input.StringValue(True) = DataStream.Read(input.size)

// read was OK so we can reset the error count to 0
ioReadErrorCount = 0

// close file
DataStream.Close

// decode structure
CloudWatcher.Record = DecodeTransferStructure(input)

// exit
return Transfer.OpenOK
[/code]

your code snippet provides no relevant information, as anything that might help point out the issue is most likely inside your Data_Transfer object.

Could input.size be short somehow and the last byte isn’t being read? Try logging the sizes…

dim data As String = DataStream.Read(input.size) System.DebugLog "data length: " + Str( LenB(data) ) System.DebugLog "input.size: " + Str( input.size )

OK, here is the Data-Transfer structure definition. As I mentioned it has a length of 613 bytes and the problematic item is the last boolean.

I’m looking at Will’s idea now …

AmbientTemp As Double
  CloudProcessed  As Double
  CloudTemp   As Double
  TempUnit    As String * 1
  SensorTemp  As Double
  RainCycles  As Double
  RainHeater  As Double
  RainTemp    As Double
  Brightness  As Double
  Switch      As Double
  ReadCycle   As Double
  DewPoint    As Double
  Humidity    As Double
  AtmPressure As Double
  WindSpeed   As Double
  WindDir     As Double
  GustSpeed   As Double
  GustDir     As Double
  LastReading As Double
  HeaterStat  As String * 30
  HeaterMsg   As Integer
  ThresholdClear   As Double
  ColourClear   As color
  StringClear   As String * 20
  ThresholdCloud as double
  ColourCloud   As color
  StringCloud   As String * 20
  ThresholdOvercast   As Double
  ColourOvercast   As color
  StringOvercast   As String * 20
  ThresholdDry    As Double
  ColourDry    As color
  StringDry    As String * 20
  ThresholdWet    As Double
  ColourWet    As color
  StringWet    As String * 20
  ThresholdRain    As Double
  ColourRain    As color
  StringRain    As String * 20
  ThresholdDark     As Double
  ColourDark     As color
  StringDark     As String * 20
  ThresholdLight    As Double
  ColourLight     As color
  StringLight     As String * 20
  ThresholdBright     As Double
  ColourBright     As color
  StringBright as string * 20
  RainLowTemp   As Double
  RainHighTemp   As Double
  RainLowDelta  As Double
  RainHighDelta  As Double
  RainHeatTemp    As Double
  RainHeatDur    As Double
  RainHeatCycle    As Double
  RainLowMin  As Double
  CloudTK1    As Double
  CloudTK2    As Double
  CloudTK3    As Double
  CloudTK4    As Double
  CloudTK5    As Double
  UnknownCloud   As Double
  UnknownRain    As Double
  UnknownBright     As Double
  CloudTK6 as double
  CloudTK7 as double
  SpeedUnit as string*1
IsWindPresent as boolean

[quote]
Generally you will use the Integer data type (equivalent to Int32 on 32-bit builds or Int64 on 64-bit builds) or UInteger (equivalent to UInt32 on 32-bit builds or UInt64 on 64-bit builds).[/quote]

So your data structure is a different size in a 64bit build… change the INTEGER to INT32 instead

OK, I started with Will’s investigation (see below), but in the meantime, Dave nailed it :wink:

Thanks!

22/11/2016 21:13:51.925 CloudWatcher.debug[27134]: data length: 613
22/11/2016 21:13:51.925 CloudWatcher.debug[27134]: input.size: 613

22/11/2016 21:19:07.093 CloudWatcher[27258]: data length: 613
22/11/2016 21:19:07.093 CloudWatcher[27258]: input.size: 613