Error: ';' expected! GRRR!

Discussion specific to NXT-G, NXC, NBC, RobotC, Lejos, and more.
jojoguy14
Posts: 155
Joined: 29 Sep 2010, 12:49
Contact:

Error: ';' expected! GRRR!

Post by jojoguy14 »

Hey there everyone!

I'm trying to figure out the new Bricxcc 3.3.8.8 version with the new RS-485 communication controls. here's my code:

Code: Select all

task main();
     OnFwd(CONN_HS4, OUT_A, 50);
     Wait(SEC_1);
     Off(CONN_HS4, OUT_A);
But, when I compile it, there are 3 errors on lines 2,3 and 4 saying that a ";" was expected. but, don't I already have those at the end of each line???

jojoguy10
Creator of LEGO-X TechN'XT! (http://lego-x.com http://techn-xt.blogspot.com)
Known as jojoguy10
m-goldberg
Posts: 73
Joined: 29 Sep 2010, 12:05

Re: Error: ';' expected! GRRR!

Post by m-goldberg »

The line "task main()" should not be terminated with ;

The other three lines of code should be surrounded with { ... }.
Regards, Morton
jojoguy14
Posts: 155
Joined: 29 Sep 2010, 12:49
Contact:

Re: Error: ';' expected! GRRR!

Post by jojoguy14 »

You mean like this?

Code: Select all

task main()
    { 
     OnFwd(CONN_HS4, OUT_A, 50);
     Wait(SEC_1);
     Off(CONN_HS4, OUT_A);
     }
Creator of LEGO-X TechN'XT! (http://lego-x.com http://techn-xt.blogspot.com)
Known as jojoguy10
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: Error: ';' expected! GRRR!

Post by mattallen37 »

Like that, only typically, white space would be more like this.

Code: Select all

task main()
{
  OnFwd(CONN_HS4, OUT_A, 50);
  Wait(SEC_1);
  Off(CONN_HS4, OUT_A);
}
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
muntoo
Posts: 834
Joined: 01 Oct 2010, 02:54
Location: Your Worst Nightmare
Contact:

Re: Error: ';' expected! GRRR!

Post by muntoo »

mattallen37 wrote:Like that, only typically, white space would be more like this.

Code: Select all

task main()
{
  OnFwd(CONN_HS4, OUT_A, 50);
  Wait(SEC_1);
  Off(CONN_HS4, OUT_A);
}
Actually, there's lots of different coding styles, but I prefer this:

Code: Select all

class Animal
{
public:
    string name;
};

task main()
{
    Animal robot;
    robot.name = "Marvin";
    NumOut(0, 8, 6 * 9, 0);
    NumOut(0, 0, 42, 0);
    Wait(1000);
}
Also, I indent using tabs with width of 4 spaces.
Image

Commit to LEGO Mindstorms Robotics Stack Exchange:
bit.ly/MindstormsSE


Commit to LEGO Stack Exchange: bit.ly/Area51LEGOcommit
jojoguy14
Posts: 155
Joined: 29 Sep 2010, 12:49
Contact:

Re: Error: ';' expected! GRRR!

Post by jojoguy14 »

Sorry about all of this, I'm a noobie at Bricxcc. Anyway, I tried that, Mattallen, but it shows new errors:
Line 3: Error: ')' expected
Line 3: Error: ';' expected
Line 4: Unmatched close parenthesis
Line 4: Error: ';' expected
Line 5: Unmatched close parenthesis
Line 5: Error: ')' expected
Line 5: Error: ';' expected

Code: Select all

task main()
{
  OnFwd(CONN_HS4, OUT_A, 50);
  Wait(SEC_1);
  Off(CONN_HS4, OUT_A);
}
So...could this just be a bug? Maybe?

jojoguy10
Creator of LEGO-X TechN'XT! (http://lego-x.com http://techn-xt.blogspot.com)
Known as jojoguy10
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

Re: Error: ';' expected! GRRR!

Post by HaWe »

I tried my very latest published version (Bricxcc 3.3.8.8 plus test_release20101103.zip 03-Nov-2010 13:52)
but there is no such syntax supported yet, nor is a help implemented for RS485 direct control.

Maybe at Xmas?
jojoguy14
Posts: 155
Joined: 29 Sep 2010, 12:49
Contact:

Re: Error: ';' expected! GRRR!

Post by jojoguy14 »

Hmmm... weird. I thought he said that in the new 3.3.8.8 release he added RS-485 control. OK, well, thanks!

jojoguy10
Creator of LEGO-X TechN'XT! (http://lego-x.com http://techn-xt.blogspot.com)
Known as jojoguy10
afanofosc
Site Admin
Posts: 1256
Joined: 26 Sep 2010, 19:36
Location: Nashville, TN
Contact:

Re: Error: ';' expected! GRRR!

Post by afanofosc »

While I was at LEGO World I worked up some example functions for Andreas Dreier but they are definitely not part of the NXC API at this point. I'm working on some changes to the enhanced NBC/NXC firmware that will support direct commands over RS485 but it isn't quite there yet either. The most recent changes involve adding a byte to the beginning of direct and system commands sent via RS485 so that you can address them to a specific NXT (CONN_HS_ALL, CONN_HS_1, CONN_HS_2, ... CONN_HS_8). Each brick will be able to set its own RS485 address using SetHSAddress(byte hsAddr) and the HS_ADDRESS_ALL, HS_ADDRESS_1, ... HS_ADDRESS_8 constants.

The high level motor control functions that support remote brick motor control will be named differently from the existing ones (something like what you see below, perhaps).

John Hansen

Code: Select all

#define RS485

#ifdef RS485
#define theConn CONN_HS4
#else
#define theConn CONN_BT1
#endif


void OnFwdAny(byte conn, byte output, char speed)
{
  if (conn == CONN_BT0)
    OnFwd(output, speed);
  else
    RemoteSetOutputState(conn, output, speed, OUT_MODE_MOTORON+OUT_MODE_BRAKE, OUT_REGMODE_IDLE, 0, OUT_RUNSTATE_RUNNING, 0);
}

void OffAny(byte conn, byte output)
{
  if (conn == CONN_BT0)
    Off(output);
  else
    RemoteSetOutputState(conn, output, 0, OUT_MODE_MOTORON+OUT_MODE_BRAKE, OUT_REGMODE_IDLE, 0, OUT_RUNSTATE_RUNNING, 0);
}

void OnRevAny(byte conn, byte output, byte speed)
{
  if (conn == CONN_BT0)
    OnRev(output, speed);
  else
  {
    speed *= -1;
    RemoteSetOutputState(conn, output, speed, OUT_MODE_MOTORON+OUT_MODE_BRAKE, OUT_REGMODE_IDLE, 0, OUT_RUNSTATE_RUNNING, 0);
  }
}

long MotorRotationCountAny(byte conn, byte output)
{
  if (conn == CONN_BT0)
    return MotorRotationCount(output);
  else
  {
    OutputStateType params;
    params.Port = output;
    RemoteGetOutputState(conn, params);
    return params.RotationCount;
  }
}

task main()
{
  byte len, cmd, cnt;
  string name;
  byte data[];
  int mvolts;
#ifdef RS485
  UseRS485();
  RS485Initialize();
  SetHSDataMode(DATA_MODE_NXT);
#endif

  RemotePlayTone(theConn, TONE_A5, 1000);
  until(RemoteConnectionIdle(theConn));
  Wait(SEC_1);

  RemoteGetCurrentProgramName(theConn, name);
  TextOut(0, LCD_LINE4, name);
  Wait(SEC_5);
  ClearScreen();

  RemoteGetContactCount(theConn, cnt);
  NumOut(0, LCD_LINE4, cnt);
  Wait(SEC_5);
  ClearScreen();

  RemoteGetConnectionCount(theConn, cnt);
  NumOut(0, LCD_LINE4, cnt);
  Wait(SEC_5);
  ClearScreen();

  RemoteGetBatteryLevel(theConn, mvolts);
  NumOut(0, LCD_LINE4, mvolts);
  Wait(SEC_5);
  ClearScreen();

  OutputStateType params;
  params.Port = OUT_A;
  while (true) {
    ClearScreen();
    if (RemoteGetOutputState(theConn, params) != NO_ERR)
      break;
    NumOut(0, LCD_LINE1, params.Power);
    NumOut(0, LCD_LINE2, params.Mode);
    NumOut(0, LCD_LINE3, params.RegMode);
    NumOut(0, LCD_LINE4, params.TurnRatio);
    NumOut(0, LCD_LINE5, params.RunState);
    NumOut(0, LCD_LINE6, params.TachoLimit);
    NumOut(0, LCD_LINE7, params.TachoCount);
    NumOut(0, LCD_LINE8, params.RotationCount);
    Wait(MS_50);
  }  

  while (true) {
    OnFwdAny(CONN_BT1, OUT_A, 75);
    Wait(SEC_4);
    OnRevAny(CONN_BT1, OUT_A, 75);
    Wait(SEC_4);
    OffAny(CONN_BT1, OUT_A);
    Wait(SEC_1);
    NumOut(0, LCD_LINE1, MotorRotationCountAny(CONN_BT1, OUT_A));
  }

  Stop(true);
  
}
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: Error: ';' expected! GRRR!

Post by mattallen37 »

muntoo wrote:Actually, there's lots of different coding styles, but I prefer this:
...
Also, I indent using tabs with width of 4 spaces.
Well, as you say, there are many different ways of using white space. When I program in BASIC, I only indent one space, but in NXC and NQC, I indent two spaces. I also use tab, but I have it set to 2 spaces.
jojoguy14 wrote:... So...could this just be a bug? Maybe?
Well, I didn't compile the code, I was just mentioning the whole thing with white space. I honestly doubted that it would compile, seeing an extra parameter in the OnFwd and Off commands.

Don't start using NXC with anything related to RS485. Start by making simple programs, and grow from them. The "NXC_tutorial" is a great place to start. In it, you can learn a TON about using NXC (through practice), but also a lot about syntax, white space, and fixing errors that cause compiler errors.
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
Post Reply

Who is online

Users browsing this forum: Semrush [Bot] and 1 guest