Finally sometings change .... I arrange the code in these manner:
const char *nmlfile =
"/home/bkt/linuxcnc-dev/configs/common/linuxcnc.nml";
RCS_STAT_CHANNEL *stat = new RCS_STAT_CHANNEL(emcFormat, "emcStatus",
"xemc", nmlfile);
RCS_CMD_CHANNEL *cmd = new RCS_CMD_CHANNEL(emcFormat, "emcCommand",
"xemc", nmlfile, 0);
NML *error = new NML(emcFormat, "emcError", "xemc", nmlfile);
/***************** start while cicle with some non-relevant code
**************************/
if(counter>=50 && counter<51)
{
QTextStream(stdout) << "state_msg try zone" << endl;
EMC_TASK_SET_STATE *state_msg = (EMC_TASK_SET_STATE
*)malloc(sizeof (cmd));
QTextStream(stdout) << "spy 1" << endl;
// state_msg->clear(); /* these not work because try to
clear empty array? */
QTextStream(stdout) << "spy 2" << endl;
state_msg->state = EMC_TASK_STATE_OFF;
QTextStream(stdout) << "spy 3" << endl;
state_msg->serial_number = ++emcCommandSerialNumber;
QTextStream(stdout) << "actual value of state_msg: " <<
state_msg->state << endl;
QTextStream(stdout) << "these steps seems right .. now
try to write" << endl;
cmd->write(state_msg);
//emcCommandBuffer->write(state_msg);
QTextStream(stdout) << "just write on emcCommandBuffer"
<< endl;
free(state_msg);
}
counter++;
/*************** thread continue ********************/
and the terminal output was these:
state_msg try zone
spy 1
spy 2
spy 3
actual value of state_msg: 3
these steps seems right .. now try to write
libnml/cms/cms_in.cc 1476: CMS: emcCommand message queue is full.
libnml/cms/cms_in.cc 1477: (continued) CMS: Message requires
139790984994912 bytes but only 0 bytes are left.
**********************************************************
* Current Directory = /home/bkt/linuxcnc-dev
*
**********************************************************
* BufferName = emcCommand
* BufferType = 0
* ProcessName = xemc
* Configuration File = /home/bkt/linuxcnc-dev/configs/common/linuxcnc.nml
* CMS Status = -7 (CMS_QUEUE_FULL:= A write failed because queuing was
enabled but there was no room to add to the queue. )
* Recent errors repeated:
CMS: emcCommand message queue is full.
(continued) CMS: Message requires 139790984994912 bytes but only 0 bytes
are left.
* BufferLine: B emcCommand SHMEM localhost 8192 0
0 1 16 1001 TCP=5005 xdr queue confirm_write serial
* ProcessLine: P xemc emcCommand LOCAL localhost W
0 10.0 0 10
* error_type = 8 ( )
************************************************************
just write on emcCommandBuffer
Obviusly there is some error .... but at least now I have an intellegible
answer from terminal .... Now I know queque is full because I not start one
.... I still don't know how to start the queque, but at least I know there
is this to do.
If anyone can suggest it to me, it is welcome.
Good end of the year to all and a good start for a great 2020 to all
those who deal with Linuxcnc.
Il giorno lun 30 dic 2019 alle ore 15:26 theman whosoldtheworld <
[email protected]> ha scritto:
> @ N *for sure problem is related to gcc version and qt *.... because
> if run other ubuntu 18.04 with gcc 5.x all work like my develop pc that
> contains gcc 5.5.
>
>
> Any how now I have other problem related previous post .....
>
> if(counter>=50 && counter<51)
> {
> QTextStream(stdout) << "state_msg try zone" << endl;
> EMC_TASK_SET_STATE *state_msg = (EMC_TASK_SET_STATE
> *)malloc(sizeof (EMC_TASK_SET_STATE));
> QTextStream(stdout) << "spy 1" << endl;
> // state_msg->clear(); /* these not work because try to
> clear empty array? */
> QTextStream(stdout) << "spy 2" << endl;
> state_msg->state = EMC_TASK_STATE_OFF;
> QTextStream(stdout) << "spy 3" << endl;
> state_msg->serial_number = ++emcCommandSerialNumber;
> QTextStream(stdout) << "actual value of state_msg: " <<
> state_msg->state << endl;
> QTextStream(stdout) << "these steps seems right .. now
> try to write" << endl;
> emcCommandBuffer->write(state_msg);
> QTextStream(stdout) << "just write on emcCommandBuffer"
> << endl;
> free(state_msg);
>
> }
>
> counter++;
>
> get these terminal output:
>
>
>
>
>
>
>
> *state_msg try zonespy 1spy 2spy 3actual value of state_msg: 3these steps
> seems right .. now try to writeSegmentation error (core dump creato)*
>
> Anyone know because these row is not right?
> emcCommandBuffer->write(state_msg);
>
> error on malloc?? I need to call state_msg->update()?? I need to implement
> a function like these?
>
> int emcCommandSend(RCS_CMD_MSG & cmd)
> {
> // write command
> if (emcCommandBuffer->write(&cmd)) {
> return -1;
> }
> emcCommandSerialNumber = cmd.serial_number;
> return 0;
> }
>
> Really not know why these.
>
> Accept any suggest.
>
>
>
>
> Il giorno sab 28 dic 2019 alle ore 08:40 N <[email protected]>
> ha scritto:
>
>> I would use the latest version available in whatever distribution you
>> happen to use but are not totally sure where sure where might be some issue
>> with some version. I compile Linuxcnc for myself and never thought to much
>> about which version of the compiler to use.
>>
>> I assume the warnings are about comppiled code then they should be there
>> whatever version of compiler you use. To get rid of the warnings you have
>> to figure out a better way to write program if possible, sometimes it's
>> possible but not always. If you wrote the code warnings are about you of
>> course have to check it to make sure there is no problem.
>>
>>
>> > other problem .... I try to copy my project on ubuntu 18.04 pc with gcc
>> 7.4
>> > .... I have a lot of warning .... the major issue seems stdio.hand
>> cstdlib
>> > is not well accept from qt + gcc7.4 ..... wath is the ideal version of
>> gcc
>> > for use with Linuxcnc file?
>> >
>> > Il giorno ven 27 dic 2019 alle ore 18:47 N <
>> [email protected]>
>> > ha scritto:
>> >
>> > > EMC_TASK_SET_STATE state_msg;
>> > > There is no malloc because memory is allocated automatically then
>> function
>> > > is entered and deallocated automatically then it exit. It is allocated
>> > > stack like and most probably on the stack but are not sure this is
>> always
>> > > the case.
>> > >
>> > > Local variable I consider the best method to allocate memory then it
>> could
>> > > be used for several reasons, usually most important because it is a
>> local
>> > > variable. But it also have advantage memory could be allocated with
>> > > increasing pointer, this is fast and deterministic. Think ADA have a
>> method
>> > > so that pointer to allocated memory is not remembered by misstake at
>> > > compile time but not C/C++. If you do not know what the stack is, it
>> is a
>> > > pointer to a memory set aside this purpose, then a function is called
>> > > adress before jump is stored on stack while stack pointer is updated
>> > > increased/decreased, then function exit it is the opposite order.
>> malloc
>> > > have to find a free area while stack like memory just
>> increase/decrease a
>> > > pointer but it only work for local variables in functions.
>> > >
>> > >
>> > > Variable is initialized by row below although I are not sure all
>> fields
>> > > are initialized. Compiler may warn if it is not initialized but as I
>> > > remember it will not warn if some fields are unitialized.
>> > > state_msg.state = EMC_TASK_STATE_ESTOP;
>> > >
>> > >
>> > > malloc return a pointer to "void" which is more or less equivalent to
>> > > pointer to unknown data type which must be the reason you get "no
>> viable
>> > > conversion from int to EMC_TASK_SET_STATE" warning. You have to use
>> type
>> > > conversion to get rid of warning (EMC_TASK_SET_STATE)malloc(...) and
>> make
>> > > sure correct size is allocated by using sizof(...) and you also have
>> to
>> > > remember deallocate/free memory then not used anymore but not before.
>> > >
>> > >
>> > >
>> > >
>> > >
>> > > > >
>> > > > > Memory may be allocated with malloc but unless function
>> > > > > emcCommandBuffer->write(...) store the pointer internally, copy
>> data
>> > > > > internally is below might be a much better idea. If state_msg
>> variable
>> > > is
>> > > > > not used further down or at least is not supposed the block will
>> also
>> > > limit
>> > > > > life time of variable.
>> > > > >
>> > > >
>> > > > this row of code is extract from shcom.cc:
>> > > >
>> > > > int emcCommandSend(RCS_CMD_MSG & cmd)
>> > > > {
>> > > > // write command
>> > > > if (emcCommandBuffer->write(&cmd)) {
>> > > > return -1;
>> > > > }
>> > > > emcCommandSerialNumber = cmd.serial_number;
>> > > > return 0;
>> > > > }
>> > > >
>> > > > int sendEstop()
>> > > > {
>> > > > EMC_TASK_SET_STATE state_msg;
>> > > >
>> > > > state_msg.state = EMC_TASK_STATE_ESTOP;
>> > > > emcCommandSend(state_msg);
>> > > > if (emcWaitType == EMC_WAIT_RECEIVED) {
>> > > > return emcCommandWaitReceived();
>> > > > } else if (emcWaitType == EMC_WAIT_DONE) {
>> > > > return emcCommandWaitDone();
>> > > > }
>> > > >
>> > > > return 0;
>> > > > }
>> > > >
>> > > > but there is not malloc for state_msg and not see where is
>> initialized
>> > > ....
>> > > >
>> > > > In my row code is the same situation .... but if try to use malloc
>> obtain
>> > > > warning like "no viable conversion from int to EMC_TASK_SET_STATE"
>> ....
>> > > is
>> > > > because I try to use malloc with bad variable type?
>> > > > In my QtDro.h file I use these .hh file of Lcnc:
>> > > >
>> > > > #include "include/cmd_msg.hh"
>> > > > #include "include/stat_msg.hh"
>> > > > #include "include/emc_nml.hh"
>> > > > #include <stat_msg.hh>
>> > > > #include <cmd_msg.hh>
>> > > > #include <nml.hh>
>> > > > #include "emc.hh" // EMC NML
>> > > > #include "include/emcglb.h" // EMC_NMLFILE,
>> > > TRAJ_MAX_VELOCITY,
>> > > > TOOL_TABLE_FILE
>> > > > #include "include/emccfg.h" // DEFAULT_TRAJ_MAX_VELOCITY
>> > > > #include "inifile.hh" // INIFILE
>> > > >
>> > > > Not understand how to initialize state_msg.
>> > > >
>> > > > thanks and good end of 2019 and new 2020 at all.
>> > > >
>> > > > bkt
>> > > >
>> > > > Il giorno gio 19 dic 2019 alle ore 17:54 N <
>> [email protected]
>> > > >
>> > > > ha scritto:
>> > > >
>> > > > > > just a guess.
>> > > > > >
>> > > > > > EMC_TASK_SET_STATE *state_msg;
>> > > > > >
>> > > > > > state_msg is a pointer, yet no memory allocated for it.
>> > > > > >
>> > > > > > state_msg->state = EMC_TASK_STATE_OFF;
>> > > > > >
>> > > > > > you try to write in a memory space that officially has no memory
>> > > > > assigned yet.
>> > > > > >
>> > > > > > ju
>> > > > > You are correct no memory assigned. Maybe no warning for using an
>> > > > > unitialized variable, if turned a warning would be issued for
>> using
>> > > > > unitizialized variable.
>> > > > >
>> > > > > Memory may be allocated with malloc but unless function
>> > > > > emcCommandBuffer->write(...) store the pointer internally, copy
>> data
>> > > > > internally is below might be a much better idea. If state_msg
>> variable
>> > > is
>> > > > > not used further down or at least is not supposed the block will
>> also
>> > > limit
>> > > > > life time of variable.
>> > > > >
>> > > > > {
>> > > > > EMC_TASK_SET_STATE state_msg;
>> > > > >
>> > > > > state_msg.state = EMC_TASK_STATE_OFF;
>> > > > > state_msg.serial_number = ++emcCommandSerialNumber;
>> > > > > emcCommandBuffer->write(&state_msg);
>> > > > > }
>> > > > >
>> > > > >
>> > > > > _______________________________________________
>> > > > > 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
>> > >
>> > >
>> > > --
>> > > N <[email protected]>
>> > >
>> > >
>> > > _______________________________________________
>> > > 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