alias problem

  • 1
  • 2
  • Seite 1 von 2
Avra
Schreiberling
Avatar
Geschlecht:
Herkunft: Belgrade, Serbia
Alter: 54
Homepage: rs.linkedin.com/in…
Beiträge: 653
Dabei seit: 07 / 2002
Betreff:

alias problem

 · 
Gepostet: 22.06.2014 - 01:41 Uhr  ·  #1
I have a shared unit with serial communication protocol process, and in it's uses section there is a project dependent unit which defines aliases like this:
Code
alias
  // Communication protocol will be on serial port 2
  SerInpComm   = SerInp2;   // serial port alias
  RxBufferComm = RxBuffer2; // serial buffer alias

In theory that should let me use communication protocol in many projects running on different ports defined in that project dependent unit.

First I had a problem which could be simplified to this code snippet:
Code
    MyStr := SerInp2 + SerInp2;                   // this works
    MyStr := SerInpComm + SerInpComm;             // doesn't compile
    MyStr := char(SerInpComm) + char(SerInpComm); // workaround
As you can see I have solved this problem with a workaround.

But then this showed up which I don't know how to solve:
Code
  if WaitPipe(RxBufferComm, COMM_TIMEOUT_TICKS) then // compilation error

Is there some workaround for using alias with WaitPipe()?
rh
Administrator
Avatar
Geschlecht:
Herkunft: Germany
Alter: 25
Homepage: e-lab.de
Beiträge: 5558
Dabei seit: 03 / 2002
Betreff:

Re: alias problem

 · 
Gepostet: 22.06.2014 - 19:37 Uhr  ·  #2
Hello Avra,

Alias is only active for one, the next, statement.

rolf
Avra
Schreiberling
Avatar
Geschlecht:
Herkunft: Belgrade, Serbia
Alter: 54
Homepage: rs.linkedin.com/in…
Beiträge: 653
Dabei seit: 07 / 2002
Betreff:

Re: alias problem

 · 
Gepostet: 22.06.2014 - 21:31 Uhr  ·  #3
Zitat geschrieben von rh
Alias is only active for one, the next, statement.

Sorry, I think that I just don't get it since your answer confused me even more and my understanding of XMega_Alias demo and compiler documentation. Especially since in demonstration code below these two lines using aliases compile:
Code
  c := SerInpComm;
  Write(SerOutComm, c);

and this one does not compile:
Code
  WaitPipe(RxBufferComm)

Changing alias order or code order didn't make any difference. Trying to use alias RxBufferComm breaks compilation. :crybaby:

Could you please tell me what I need to change to be able to use RxBufferComm alias since that is not obvious to me and I still don't get it? :wall:

Code
program Test;

device = mega64, VCC=3.3;

import SysTick, SerPort, SerPort2;

from System import Processes;

define
  ProcClock      = 16000000;       {Hertz}
  SysTick        = 10;             {msec}
  StackSize      = $0064, iData;
  FrameSize      = $0064, iData;
  Scheduler      = iData;
  SerPort        = 9600, Stop1;    {Baud, StopBits|Parity}
  RxBuffer       = 8, iData;
  TxBuffer       = 8, iData;
  SerPort2       = 9600, Stop1;    {Baud, StopBits|Parity}
  RxBuffer2      = 8, iData;
  TxBuffer2      = 8, iData;

implementation

type

{$IDATA}
var

alias
  RxBufferComm = RxBuffer; // serial port input buffer alias
  SerInpComm   = SerInp;   // serial port input alias
  SerOutComm   = SerOut;   // serial port output alias

process HcpComm($40, $100: iData);
var
  c: char;
begin
  //WaitPipe(RxBufferComm); // COMPILER ERROR: var expected
  WaitPipe(RxBuffer);       // workaround without alias works
  c := SerInpComm;
  Write(SerOutComm, c);     // echo input
end;

begin
  Start_Processes;
  WriteLn(SeroutComm, 'I will echo your typing...');
  loop
    nop;
  endloop;
end Test.
rh
Administrator
Avatar
Geschlecht:
Herkunft: Germany
Alter: 25
Homepage: e-lab.de
Beiträge: 5558
Dabei seit: 03 / 2002
Betreff:

Re: alias problem

 · 
Gepostet: 22.06.2014 - 22:00 Uhr  ·  #4
Hello Avra,

sorry, my mistake. Of course ALIAS is valid until the next var or const label appears.

rolf
Avra
Schreiberling
Avatar
Geschlecht:
Herkunft: Belgrade, Serbia
Alter: 54
Homepage: rs.linkedin.com/in…
Beiträge: 653
Dabei seit: 07 / 2002
Betreff:

Re: alias problem

 · 
Gepostet: 22.06.2014 - 22:32 Uhr  ·  #5
Zitat geschrieben von rh
sorry, my mistake. Of course ALIAS is valid until the next var or const label appears.

So why in above code this line can not compile when uncommented:
Code
//WaitPipe(RxBufferComm); // COMPILER ERROR: var expected

There is no const or var between alias and this line. I have moved procedural var into global var so there is not a single var at all between alias and this line and I still can not compile.

What do I need to change to be able to compile above code when using RxBufferComm alias?
rh
Administrator
Avatar
Geschlecht:
Herkunft: Germany
Alter: 25
Homepage: e-lab.de
Beiträge: 5558
Dabei seit: 03 / 2002
Betreff:

Re: alias problem

 · 
Gepostet: 23.06.2014 - 13:36 Uhr  ·  #6
Hello Avra,

WaitPipe is a very special construction and was not intended to be
used with ALIAS. But now it is supported.

rolf
Avra
Schreiberling
Avatar
Geschlecht:
Herkunft: Belgrade, Serbia
Alter: 54
Homepage: rs.linkedin.com/in…
Beiträge: 653
Dabei seit: 07 / 2002
Betreff:

Re: alias problem

 · 
Gepostet: 23.06.2014 - 20:05 Uhr  ·  #7
Zitat geschrieben von rh
WaitPipe is a very special construction and was not intended to be
used with ALIAS. But now it is supported.

I have tested and... IT COMPILES, IT COMPILES IT COMPILES !!! :D
=D> :-({|= =D> :occasion7: 👋

Now I can share communication unit between different projects without tons of ugly IFDEFs covering all possible AVR serial ports combination in code.
🆒 :juggle:

THANK YOU ROLF!
:cheers: :occasion5: 👍
rh
Administrator
Avatar
Geschlecht:
Herkunft: Germany
Alter: 25
Homepage: e-lab.de
Beiträge: 5558
Dabei seit: 03 / 2002
Betreff:

Re: alias problem

 · 
Gepostet: 23.06.2014 - 20:40 Uhr  ·  #8
Hello Avra,

some things are easy to implement, like this one.
Others are not, like passing bits to a function.

rolf
  • 1
  • 2
  • Seite 1 von 2
Gewählte Zitate für Mehrfachzitierung:   0

Registrierte in diesem Topic

Aktuell kein registrierter in diesem Bereich

Die Statistik zeigt, wer in den letzten 5 Minuten online war. Erneuerung alle 90 Sekunden.
MySQL Queries: 15 · Cache Hits: 14   125   139 · Page-Gen-Time: 0.027292s · Speichernutzung: 2 MB · GZIP: ein · Viewport: SMXL-HiDPI