seisFile icon indicating copy to clipboard operation
seisFile copied to clipboard

SeedLinkReader Line Ending

Open drammelt opened this issue 5 years ago • 3 comments

SeedLinkReader expects \r\n ending and throws an exception if the \n does not follow the \r

// next should now be a \n, so just eat it        
next = in.read();        
if (next != '\n') {            
    throw new SeedlinkException("Got \\r but not followed by \\n buf: '"+buf.toString()+"' next: " + next);        
}        
return buf.toString();

We have a server that only outputs the \r and works fine with the tool we have been using until now, slinktool from https://ds.iris.edu/ds/nodes/dmc/software/downloads/slinktool

My expectation is that the parser would end if either a \r or \n is found as this would match all line ending formats and if the \n is missing it is irrelevant. This would also mean the exception is not needed.

So is the \n absolutely necessary to conform with the mseed format?

drammelt avatar Jun 10 '21 02:06 drammelt

From the slinktool changelog

Do not send terminating NULL characters in command strings sent to the server. The protocol stipulates that commands must be terminated with a carriage return (\r) followed by an optional new line (\n). The library now strictly terminates commands with only a carriage return.

drammelt avatar Jun 10 '21 02:06 drammelt

Unfortunately seedlink doesn't have a real specification, so it is hard know how all servers behave, much less to enforce things like this. I can update the code to allow \r, \n or \r\n as line endings.

Fixed in https://github.com/crotwell/seisFile/commit/31839c0334c264a38b834fa8dc77e59fc3062f20

crotwell avatar Jun 10 '21 14:06 crotwell

released in ver 2.0.1

crotwell avatar Jun 10 '21 19:06 crotwell