View unanswered posts | View active topics It is currently Mon Nov 18, 2019 8:06 pm






Reply to topic  [ 5 posts ] 
EV3, V4.30 increment SHORT variables is failing 
Author Message
Rookie

Joined: Thu Nov 06, 2014 2:23 am
Posts: 9
Post EV3, V4.30 increment SHORT variables is failing
I am running the RobotC 4.30 on Windows 8.1 with EV3 as target. The ++ operation increments a short variable by 256 instead of 1.

Code:
char   u8   = 100;
short i16   = 200;
long  i32 = 300;
task main() {
   long i;
   char buffer[64];
   clearDebugStream();
   
   GetFWBuild(sizeof(buffer), buffer); 
   writeDebugStream("FWBuild   = ");
   writeDebugStream(buffer);
   
   GetFWVersion(sizeof(buffer), buffer); 
   writeDebugStream("\nFWVersion = ");
   writeDebugStream(buffer);
   
   GetHWVersion(sizeof(buffer), buffer); 
   writeDebugStream("\nHWVersion = ");
   writeDebugStream(buffer);
   
   GetOSBuild(sizeof(buffer), buffer); 
   writeDebugStream("\nOSBuild   = ");
   writeDebugStream(buffer);
   
   GetVersion(sizeof(buffer), buffer); 
   writeDebugStream("\nVersion   = ");
   writeDebugStream(buffer);
   
   writeDebugStream("\n\nIncrements\n");
   
   for (i=0;i<10;i++) {
      writeDebugStream("u8 = %d, i16 = %d, i32 = %d\n",u8++,i16++,i32++);
  }
}


generates the following results in Debug Stream.

Quote:
FWBuild = 1411191539
FWVersion = V1.06X
HWVersion = V0.60
OSBuild = 1411191544
Version = LMS2012 V1.06X(Nov 19 2014 15:39:18)

Increments
u8 = 100, i16 = 200, i32 = 300
u8 = 101, i16 = 456, i32 = 301
u8 = 102, i16 = 712, i32 = 302
u8 = 103, i16 = 968, i32 = 303
u8 = 104, i16 = 1224, i32 = 304
u8 = 105, i16 = 1480, i32 = 305
u8 = 106, i16 = 1736, i32 = 306
u8 = 107, i16 = 1992, i32 = 307
u8 = 108, i16 = 2248, i32 = 308
u8 = 109, i16 = 2504, i32 = 309


Fri Feb 20, 2015 3:49 pm
Profile
Site Admin
Site Admin

Joined: Wed Jan 24, 2007 10:42 am
Posts: 620
Post Re: EV3, V4.30 increment SHORT variables is failing
Yep... looks like there's a bug with globally allocated "short" integers (16-bits). Local "short" doesn't seem to be affected however. Seems to be affecting both the physical robot and our internal emulator, so it might be a compiler or firmware bug.

The immediate workaround is not to use global short variables. We'll work on a solution and have a fix for the next release.

Thanks.

-----

Image

Code:
#pragma debuggerWindows("DebugStream")

char   global_u8   = 100;
short global_i16   = 200;
long  global_i32 = 300;

task main()
{
   char  local_u8   = 10;
   short local_i16  = 20;
   long  local_i32  = 30;   

   short i;
   clearDebugStream();

   writeDebugStream("Increments\n");

   for (i=0;i<10;i++)
   {
      global_u8++;
      global_i16++;
      global_i32++;
      local_u8++;
      local_i16++;
      local_i32++;
      writeDebugStream("Global: u8 = %6d, i16 = %6d, i32 = %6d\n",global_u8,global_i16,global_i32);
      writeDebugStream("Locals: u8 = %6d, i16 = %6d, i32 = %6d\n",local_u8,local_i16,local_i32);
   }
}

_________________
Timothy Friez
ROBOTC Developer - SW Engineer
tfriez@robotc.net


Fri Feb 20, 2015 4:21 pm
Profile
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1523
Post Re: EV3, V4.30 increment SHORT variables is failing
Could this be little-endian vs big-endian issue? I assume the internal word size of EV3 is 32-bit so a 16-bit short is probably represented as 32-bit internally and it looks like the increment is doing it on the upper 16-bit instead of the lower 16-bit.


Fri Feb 20, 2015 8:36 pm
Profile
Site Admin
Site Admin
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3654
Location: Rotterdam, The Netherlands
Post Re: EV3, V4.30 increment SHORT variables is failing
Nah, it really was a bug in the firmware and a fix for it has already been put in the source code for the next release. It was an endian-ness-less issue.

= Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Sun Feb 22, 2015 3:12 am
Profile WWW
Rookie

Joined: Thu Nov 06, 2014 2:23 am
Posts: 9
Post Re: EV3, V4.30 increment SHORT variables is failing
Nice word endian-ness-less


Mon Feb 23, 2015 3:06 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 5 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.