Skip to content

Commit

Permalink
Use sequence number from extra headers (/FDSN/Sequence) if present wh…
Browse files Browse the repository at this point in the history
…en writing format v2
  • Loading branch information
chad-earthscope committed Jun 13, 2024
1 parent 3ab7b67 commit 4ddece6
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
3 changes: 3 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
2024.165: 3.1.3
- Use sequence number from extra headers (/FDSN/Sequence) if present when writing format v2.

2024.148: 3.1.2
- Update yyjson to v0.9.0.
- Simplify mstl3_addmsr_recordptr() a bit.
Expand Down
4 changes: 2 additions & 2 deletions libmseed.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
extern "C" {
#endif

#define LIBMSEED_VERSION "3.1.2" //!< Library version
#define LIBMSEED_RELEASE "2024.148" //!< Library release date
#define LIBMSEED_VERSION "3.1.3" //!< Library version
#define LIBMSEED_RELEASE "2024.165" //!< Library release date

/** @defgroup io-functions File and URL I/O */
/** @defgroup miniseed-record Record Handling */
Expand Down
22 changes: 20 additions & 2 deletions pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ msr3_pack_header3 (const MS3Record *msr, char *record, uint32_t recbuflen, int8_
maxreclen = (msr->reclen < 0) ? MS_PACK_DEFAULT_RECLEN : msr->reclen;
encoding = (msr->encoding < 0) ? MS_PACK_DEFAULT_ENCODING : msr->encoding;

if (maxreclen < MINRECLEN || maxreclen > MAXRECLENv2)
if (maxreclen < MINRECLEN || maxreclen > MAXRECLEN)
{
ms_log (2, "%s: Record length is out of range: %d\n", msr->sid, maxreclen);
return -1;
Expand Down Expand Up @@ -986,7 +986,25 @@ msr3_pack_header2 (const MS3Record *msr, char *record, uint32_t recbuflen, int8_
}

/* Build fixed header */
memcpy (pMS2FSDH_SEQNUM (record), "000000", 6);

/* Use sequence number from extra headers if present */
if (yyjson_ptr_get_uint (ehroot, "/FDSN/Sequence", &header_uint))
{
if (header_uint <= 999999)
{
char seqnum[7];
snprintf (seqnum, sizeof (seqnum), "%06" PRIu64, header_uint);
memcpy (pMS2FSDH_SEQNUM (record), seqnum, 6);
}
else
{
memcpy (pMS2FSDH_SEQNUM (record), "999999", 6);
}
}
else
{
memcpy (pMS2FSDH_SEQNUM (record), "000000", 6);
}

/* Use DataQuality indicator in extra headers if present */
if (yyjson_ptr_get_str (ehroot, "/FDSN/DataQuality", &header_string) &&
Expand Down

0 comments on commit 4ddece6

Please sign in to comment.