Veins 4.7.1 and SUMO 0.30.0 retrieve Stop State from TraCI error

45 views
Skip to first unread message

Marcello Sgarbi

unread,
Jan 28, 2019, 7:39:45 AM1/28/19
to OMNeT++ Users
Hello everyone,
I've tried to retrieve the Stop State from TraCI. To do it I created a new method:

TraCICommandInterface.h:
class Vehicle {
public:
            ...
            int getStopState();

and 

TraCICommandInterface.cc:
int TraCICommandInterface::Vehicle::getStopState(){
    return traci->genericGetInt(CMD_GET_VEHICLE_VARIABLE, nodeId, VAR_STOPSTATE, RESPONSE_GET_VEHICLE_VARIABLE);
}

But when I try to use it this error occur:

A runtime error occurred:

Attempted to read past end of byte buffer -- in module (TraCIDemo11p) RSUExampleScenario.node[5].appl (id=38) ....

VAR_STOPSTATE was already present in TraCIConstants.h as VAR_STOPSTATE 0xb5 as reported in the online documentation. I'm thinking that I'm making some mistake in the return type but I don't know how to return a type "ubyte".

Christoph Sommer

unread,
Jan 28, 2019, 1:23:27 PM1/28/19
to omn...@googlegroups.com
On 28 Jan 2019, at 13:39, Marcello Sgarbi <marcel...@gmail.com> wrote:
>
> I'm thinking that I'm making some mistake in the return type but I don't know how to return a type "ubyte".

Indeed, I would suspect this to be the problem as well. The SUMO Wiki lists the result type as "byte", but you're calling a method to read an Integer (two Bytes). You'll need to write your own function for reading a Byte, I'm afraid. You might simply follow the template of the other (for Integer, Double, ...) functions:

https://github.com/sommer/veins/blob/veins-4.7.1/src/veins/modules/mobility/traci/TraCICommandInterface.cc#L701

Best,

Christoph

--
Jun.-Prof. Dr.-Ing. Christoph Sommer
Cooperative Mobile Systems (CCS Labs)
Heinz Nixdorf Institute, Paderborn University, Germany
http://www.ccs-labs.org/~sommer/

Reply all
Reply to author
Forward
0 new messages