7dps Type with CAN Comms

Support forum for users of the M1 Build

7dps Type with CAN Comms

Postby kseven on Fri Apr 10, 2026 6:20 am

I am trying to send GPS longitude and latitude over CAN bus, but am running into issues with the fixed point 7dps type using the DBC import method. In my DBC file, I am using a signed integer type with a factor of 1e-07. The code is throwing errors because a 7dps type cannot be automatically converted to an integer with a factor. I can try using the Convert.ToInteger() function, but I am assuming this will truncate the decimal points.

Code: Select all
if (This.CAN Bus neq This.CAN Bus.Not in Use)
{
   local ok = true;

   // Messsage 1
   local h = DBC.Main Bus.ECU GPS1.TxOpen();
   
   local lat = Convert.ToInteger(GPS.Latitude) * 10000000;
   local long = Convert.ToInteger(GPS.Longitude) * 10000000;
   
   DBC.Main Bus.ECU GPS1.TxInitialise(h);
   DBC.Main Bus.ECU GPS1.GPS Latitude.SetInteger(h, lat);
   DBC.Main Bus.ECU GPS1.GPS Longitude.SetInteger(h, long);
   ok = DBC.Main Bus.ECU GPS1.Tx(h);
   
   ok = ok;
}


I tried this too, but it throws errors trying to convert a constant integer to a 7dps.

Code: Select all
local lat = Convert.ToInteger(GPS.Latitude * Convert.ToFixed7DP(10000000));


I would appreciate any suggestions. Thank you!
kseven
 
Posts: 8
Joined: Sat Feb 17, 2024 9:30 am

Return to M1 Build

Who is online

Users browsing this forum: No registered users and 1 guest