Commit e94a665b authored by Alessandro Rubini's avatar Alessandro Rubini

diag: print send/recv stamp with added ps field

format is "%9d.%09d.%03d". This is not properly a flating point number, but
counting 9 digits is already heavy, I'd better not have a 12-digit field
(which, btw, will be wrongly converted by 32-bit parsers).

This comes from a similar change by Peter Jansweijer from nikhef,
for absolute-calibration work.
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent 31f08f19
......@@ -197,15 +197,16 @@ static int fsm_unpack_verify_frame(struct pp_instance *ppi,
int pp_state_machine(struct pp_instance *ppi, uint8_t *packet, int plen)
{
struct pp_state_table_item *ip;
struct pp_time *t = &ppi->last_rcv_time;
int state, err = 0;
int msgtype;
if (plen > 0) {
msgtype = packet[0] & 0xf;
pp_diag(ppi, frames, 1,
"RECV %02d bytes at %9d.%09d (type %x, %s)\n", plen,
(int)ppi->last_rcv_time.secs,
(int)(ppi->last_rcv_time.scaled_nsecs >> 16),
"RECV %02d bytes at %9d.%09d.%03d (type %x, %s)\n",
plen, (int)t->secs, (int)(t->scaled_nsecs >> 16),
((int)(t->scaled_nsecs & 0xffff) * 1000) >> 16,
msgtype, pp_msgtype_info[msgtype].name);
}
......
......@@ -304,6 +304,7 @@ int st_com_master_handle_sync(struct pp_instance *ppi, unsigned char *buf,
int __send_and_log(struct pp_instance *ppi, int msglen, int chtype)
{
int msgtype = ((char *)ppi->tx_ptp)[0] & 0xf;
struct pp_time *t = &ppi->last_snt_time;
int ret;
ret = ppi->n_ops->send(ppi, ppi->tx_frame, msglen + ppi->tx_offset,
......@@ -316,9 +317,9 @@ int __send_and_log(struct pp_instance *ppi, int msglen, int chtype)
return PP_SEND_ERROR;
}
/* FIXME: diagnosticst should be looped back in the send method */
pp_diag(ppi, frames, 1, "SENT %02d bytes at %d.%09d (%s)\n", msglen,
(int)(ppi->last_snt_time.secs),
(int)(ppi->last_snt_time.scaled_nsecs >> 16),
pp_diag(ppi, frames, 1, "SENT %02d bytes at %d.%09d.%03d (%s)\n",
msglen, (int)t->secs, (int)(t->scaled_nsecs >> 16),
((int)(t->scaled_nsecs & 0xffff) * 1000) >> 16,
pp_msgtype_info[msgtype].name);
if (chtype == PP_NP_EVT && is_incorrect(&ppi->last_snt_time))
return PP_SEND_NO_STAMP;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment