CSV protocol handler: EOL character?

Post Reply
CordWinkelmann
Posts: 2
Joined: Thu Oct 16, 2014 12:19 pm

CSV protocol handler: EOL character?

Post by CordWinkelmann » Thu Oct 16, 2014 12:37 pm

Hello,

I am using the CSV protocol handler to get data from the TCPClient transport handler.
The server sends the Data in the format value1,value1\n.
The schema is ['A', 'DOUBLE'], ['B', 'DOUBLE'], and so on.

The values are transmitted correctly but the \n results in an <ERROR> value. If my schema contains more values than the sent string, the data in Odysseus shows A: value1, B: value2, C: <Error>, D: <null>. So my question is: what kind of EOL sign does the CSV protocol handler expect? Do I need a schema value for it or can that be omitted?

The console gives me an java.lang.ArrayIndexOutOfBoundsException but I think this is because the schema is longer than the transmitted string.

Best regards
Cord Winkelmann

User avatar
Marco Grawunder
Posts: 272
Joined: Tue Jul 29, 2014 10:29 am
Location: Oldenburg, Germany
Contact:

Re: CSV protocol handler: EOL character?

Post by Marco Grawunder » Thu Oct 16, 2014 1:05 pm

The csv handler expects \n or \n\r as line endmarkers.

Here:

viewtopic.php?f=18&t=4

is a similar discussion.

A schema is necessary.

Can you give your source definition?

Can you state the line number with the ArrayIndexOutOfBoundsException?

CordWinkelmann
Posts: 2
Joined: Thu Oct 16, 2014 12:19 pm

Re: CSV protocol handler: EOL character?

Post by CordWinkelmann » Thu Oct 16, 2014 8:13 pm

Hello Mr. Grawunder,

thank's for your reply. So basically my send function looks like this:

// Schnipp
sprintf(buffer, "%d,%d\n", value1, value2);
if ( (n = write( sockfd, buffer, strlen(buffer) ) ) < 0 )
error("ERROR writing to socket");
//Schnapp

This results in the mentioned string "value1,value2\n".

Here is my source definition:

#PARSER PQL
#TRANSCFG Standard
#RUNQUERY
sensor ::= ACCESS({source='sensor_adc',
wrapper='GenericPush',
transport='TCPClient',
protocol='CSV',
dataHandler='Tuple',
options=[
['host', '192.168.1.15'],
['port', '55555'],
['ByteOrder', 'LittleEndian']
],
schema=[
['A1', 'DOUBLE'],
['A2', 'DOUBLE'],
['EOL', 'STRING']
]
})

I get all the data into Odysseus, but the EOL is <Error>.
The complete Error Message is
2087701 ERROR StreamTableEditor - Could not retrieve attributeValue - de.uniol.inf.is.odysseus.rcp.viewer.stream.table.StreamTableEditor$5.update(StreamTableEditor.java:267)
java.lang.ArrayIndexOutOfBoundsException where the first number (2087701) rises every second line by one.

User avatar
Marco Grawunder
Posts: 272
Joined: Tue Jul 29, 2014 10:29 am
Location: Oldenburg, Germany
Contact:

Re: CSV protocol handler: EOL character?

Post by Marco Grawunder » Fri Oct 17, 2014 7:55 am

Ah yes, the problem is the last attribute definition. The EOL character is removed from the input, since its not needed anymore. So

Code: Select all

#PARSER PQL
#TRANSCFG Standard
#RUNQUERY
sensor ::= ACCESS({source='sensor_adc',
wrapper='GenericPush',
transport='TCPClient',
protocol='CSV',
dataHandler='Tuple',
options=[
['host', '192.168.1.15'],
['port', '55555'],
['ByteOrder', 'LittleEndian']
],
schema=[
['A1', 'DOUBLE'],
['A2', 'DOUBLE']
]
})
should do the work.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest