You want...

If there is a new message

AND 

The connection is valid

So...

             if((stat->peek() == EMC_STAT_TYPE) && (stat->valid())) 
             {
             // Good
             }
             else
             {
             // Either bad, or no message
             }

But really, it should be

If ( !stat->valid())
{
// connection bad 
}
else
{
        int status = stat->peek()
        If ( status ==  EMC_STAT_TYPE )
        {
        // new message
        }
        Else if ( status == 0 )
        {
        // no new message
        }
        Else /* if (status == -1 )
        {
        // error reading message
        }
}

-----Original Message-----
From: theman whosoldtheworld [mailto:[email protected]] 
Sent: Wednesday, 5 December 2018 6:24 AM
To: EMC developers
Subject: Re: [Emc-developers] [Emc-users] [EMC] NML_FILE = emc.nml

Nooo ... the right code is these??:

 /***********  CASE 1 *******************/

             if((stat->peek() == EMC_STAT_TYPE) || (stat->valid())) /*
error ... these condition never valid */
             {
                 /** send my best position to ui **/
             }
             else { /** error condition?? **/ }

or these one?

 /***********  CASE 2 *******************/
             if((stat->peek() == EMC_STAT_TYPE) || (stat->valid())) /*
error ... these condition never valid */
             {
                 /** error condition?? **/
             }
             else {   /** send my best position to ui **/ }

IF THE RIGHT CASE IS 1 (ONE) ALL WORKS RIGHT ... nothing to do .... else if
the right id CASE 2 ... I have some problem ....
I not know stat->peek() .... but stat->valid() i think is boolean so
probabili I invert the condition and the right case is CASE 1 .... so my
program works.

Can you confirm these?

regards
bkt

Il giorno lun 3 dic 2018 alle ore 20:20 Frank Tkalcevic <
[email protected]> ha scritto:

> Just confirming, which line do you still get the error?  What is the
error?
>
>
> Here are some things you can check...
>
> After
>
> RCS_STAT_CHANNEL *stat = new  RCS_STAT_CHANNEL(emcFormat, "emcStatus",
> "xemc", "/home/mypc/linuxcnc-dev/configs/sim/axis/emc.nml");
>
> you can
>
> if ( !stat->valid())
> {
> // there is an error
> }
>
> Also, stat->peek() returns...
>
> -1 on error,
> 0 no new data,
> EMC_STAT new data
>
> Did you update the path to the emc.nml file in the ini file?  Both
> linuxcnc real time and your program need to use the same .nml file.
>
>
>
>
>
> -----Original Message-----
> From: theman whosoldtheworld [mailto:[email protected]]
> Sent: Monday, 3 December 2018 11:53 PM
> To: EMC developers
> Subject: Re: [Emc-developers] [Emc-users] [EMC] NML_FILE = emc.nml
>
> @franks  thanks .... never understand that I must insert in my config
> folder (or absolute path file) with emc.nml file ..... so actually as test
> pourpose I've insert in my c++ app an adbolute path like these:
>
> RCS_STAT_CHANNEL *stat = new  RCS_STAT_CHANNEL(emcFormat, "emcStatus",
> "xemc", "/home/mypc/linuxcnc-dev/configs/sim/axis/emc.nml");
>
> now nothing about error in compiling time .... the app start ... but i've
> an error in these point of code:
>
> RCS_STAT_CHANNEL *stat = new  RCS_STAT_CHANNEL(emcFormat, "emcStatus",
> "xemc", "/home/mypc/linuxcnc-dev/configs/sim/axis/emc.nml");
>
>
>              if((stat->peek() == EMC_STAT_TYPE) || (stat->valid())) /*
> error ... these condition never valid */
>              {
>                  corri = false;
>                  corriPlus = false;
>                  sendPosition(Error, Error, Error);
>
>                  qDebug() << " errore EMC_STAT_TYPE ......   ";
>              }
>              else
>              {
>                  EMC_STAT *emcStatus =
> static_cast<EMC_STAT*>(stat->get_address());
>
>                  /*std::cout << emcStatus->motion.traj.position.tran.x <<
"
> "
>                                  << emcStatus->motion.traj.position.tran.y
> << " "
>                                  << emcStatus->motion.traj.position.tran.z
> << "\n";*/
>
>                  X =
> QString(QChar::fromLatin1(emcStatus->motion.traj.position.tran.x ));
> /***********  these conversion is really wrong ****************/
>                  Y =
> QString(QChar::fromLatin1(emcStatus->motion.traj.position.tran.y )) ;
> /***********  these conversion is really wrong ****************/
>                  Z =
> QString(QChar::fromLatin1(emcStatus->motion.traj.position.tran.z )) ;
> /***********  these conversion is really wrong ****************/
>
>
>                  qDebug() << " position x:   " <<  X ;
>                  qDebug() << " position y:   " <<  Y;
>                  qDebug() << " position z:   " <<  Z;
>
>                  emit sendPosition(X, Y ,Z);
>
>    }
>
> stat is never valid or == to EMC_STAT_TYPE ... but is possible to have my
> emcStatus->motion.traj.position.tran.x,
> emcStatus->motion.traj.position.tran.y,
> emcStatus->motion.traj.position.tran.z  HEUREKA!!
>
> actually I not know why I have these situation ... I've used your emc.nml
> file .... without hidcomp and keystick part.
>
> bkt
>
> Il giorno ven 30 nov 2018 alle ore 23:17 Frank Tkalcevic <
> [email protected]> ha scritto:
>
> > This is what I use on mine...
> >
> > https://github.com/ftkalcevic/CNCConfig/blob/master/9x20lathe/emc.nml
> >
> > I've added entries for my own process, hidcomp.  The linuxcnc I'm
running
> > is a bit old, so I don't know if the buffer sizes are correct.
> >
> >
> >
> >
> > -----Original Message-----
> > From: theman whosoldtheworld [mailto:[email protected]]
> > Sent: Friday, 30 November 2018 11:34 PM
> > To: Enhanced Machine Controller (EMC)
> > Cc: EMC developers
> > Subject: Re: [Emc-developers] [Emc-users] [EMC] NML_FILE = emc.nml
> >
> > no solution for these ... if I try to insert the row obtain an error
> > relative to "impossible establish nml connection" (more or less these is
> > the messages that appear on terminal) if not insert these row if I try
to
> > ruan a c++ program like these:
> >
> > void qtdro::dro()
> > {
> >    // const QStringList args = QCoreApplication::arguments();
> >         const QStringList args = QApplication::arguments();
> >
> >
> >         if(args.isEmpty() || (args.size() < 1))
> >         {
> >             /*std::cerr << "Usage: " << argv[0] << " NMLFILE\n";*/
> >             qDebug() << "NMLFILE is not open yet";
> >             qDebug() << "args is open? ...." << args.isEmpty();
> >             qDebug() << "args.size? ....... " << args.size();
> >             qDebug() << "args.[0] contains? ....... " << args[0];
> >         }
> >         else
> >         {
> >             qDebug() << "args is open? ...." << args.isEmpty();
> >             qDebug() << "args.size? ....... " << args.size();
> >             qDebug() << "args.[0] contains? ....... " << args[0];
> >             qDebug() << "args.[0] contains? ....... " << args[1];
> >
> >             QString s0 = args[0];
> >             QString s1 = args[1];
> >             QString s2 =
> > "/home/mypc/linuxcnc-dev/configs/sim/axis/axis.ini";
> >
> >            const char *nmlfile = s2.toStdString().c_str();
> >            qDebug() << "consta chars c2 contains? ....... " <<
> > s2.toStdString().c_str();
> >            qDebug() << "consta chars c2 contains? ....... " << *c2;
> >             //RCS_STAT_CHANNEL *stat = new  RCS_STAT_CHANNEL(emcFormat,
> > "emcStatus", "xemc", nmlfile);
> >            RCS_STAT_CHANNEL *stat = new  RCS_STAT_CHANNEL(emcFormat,
> > "emcStatus", "xemc",
> "/home/mypc/linuxcnc-dev/configs/sim/axis/axis.ini");
> >
> > I've a return messages like these:
> >
> > libnml/cms/cms_cfg.cc 496: No buffer-line entry found for buffer
> emcStatus
> > in config file /home/mypc/linuxcnc-dev/configs/sim/axis/axis.ini.
> > libnml/nml/nml.cc 370: NML: cms_config returned -1.
> >
> > **********************************************************
> > * Current Directory = /home/mypc/linuxcnc-dev/scripts
> > *
> > **********************************************************
> > * BufferName = emcStatus
> > * ProcessName = xemc
> > * Config File = /home/mypc/linuxcnc-dev/configs/sim/axis/axis.ini
> > * error_type = 0 (NML_NO_ERROR)
> > ************************************************************
> >
> > libnml/nml/nml.cc 1343: NML::peek: CMS not configured.
> >
> > So my original question (make some time and post ago)  is: But in SIM
> only
> > installa (no preempt), NML server is running??
> >
> > sob ... I know my english is quite bad ... I hope was all clear ..
> >
> > bkt
> >
> >
> >
> > Il giorno mer 28 nov 2018 alle ore 15:33 andy pugh <[email protected]>
> ha
> > scritto:
> >
> > > On Wed, 28 Nov 2018 at 10:26, theman whosoldtheworld <
> > [email protected]
> > > >
> > > wrote:
> > >
> > > > [EMC] NML_FILE = emc.nml
> > > >
> > > > these row in file.ini is still valid?
> > >
> > >
> > > Some sections of code still look for it:
> > >
> > > https://github.com/LinuxCNC/linuxcnc/search?l=C%2B%2B&q=NML_FILE
> > >
> > > No version of the docs (back to 2.2 at least) has ever mentioned that
> > > entry.
> > > I think it must be the case that the default value is OK.
> > >
> > > --
> > > atp
> > > "A motorcycle is a bicycle with a pandemonium attachment and is
> designed
> > > for the especial use of mechanical geniuses, daredevils and lunatics."
> > > ? George Fitch, Atlanta Constitution Newspaper, 1916
> > >
> > > _______________________________________________
> > > Emc-users mailing list
> > > [email protected]
> > > https://lists.sourceforge.net/lists/listinfo/emc-users
> > >
> >
> > _______________________________________________
> > Emc-developers mailing list
> > [email protected]
> > https://lists.sourceforge.net/lists/listinfo/emc-developers
> >
> >
> >
> > _______________________________________________
> > Emc-developers mailing list
> > [email protected]
> > https://lists.sourceforge.net/lists/listinfo/emc-developers
> >
>
> _______________________________________________
> Emc-developers mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/emc-developers
>
>
>
> _______________________________________________
> Emc-developers mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/emc-developers
>

_______________________________________________
Emc-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-developers



_______________________________________________
Emc-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-developers

Reply via email to