Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Tammo Jan Dijkema
dt_ctrl
Commits
74756dbf
Commit
74756dbf
authored
Jun 04, 2015
by
Jeroen Vreeken
Browse files
Change trace code some more. (hopefully last time the stream format is
broken)
parent
513d855e
Changes
12
Hide whitespace changes
Inline
Side-by-side
common/trace/trace.c
View file @
74756dbf
...
...
@@ -208,7 +208,8 @@ int trace_packet_list_add(struct trace_pkt *pkt,
return
0
;
}
int
trace_packet_value_add
(
struct
trace_pkt
*
pkt
,
struct
trace_value
*
value
,
enum
trace_value_type
type
)
int
trace_packet_value_add
(
struct
trace_pkt
*
pkt
,
int
channel
,
struct
trace_value
*
value
,
enum
trace_value_type
type
)
{
size_t
entry_size
;
struct
{
...
...
@@ -223,31 +224,30 @@ int trace_packet_value_add(struct trace_pkt *pkt, struct trace_value *value, enu
case
TRACE_VALUE_TYPE_BOOL
:
case
TRACE_VALUE_TYPE_UINT8
:
case
TRACE_VALUE_TYPE_SINT8
:
entry_size
=
1
;
entry_size
=
1
+
1
;
break
;
case
TRACE_VALUE_TYPE_SINT16
:
case
TRACE_VALUE_TYPE_UINT16
:
entry_size
=
2
;
entry_size
=
2
+
1
;
break
;
case
TRACE_VALUE_TYPE_UINT32
:
case
TRACE_VALUE_TYPE_SINT32
:
case
TRACE_VALUE_TYPE_FLOAT
:
default:
entry_size
=
4
;
entry_size
=
4
+
1
;
break
;
}
if
(
!
pkt
->
len
)
{
size_t
len
=
sizeof
(
struct
trace_header
)
+
sizeof
(
struct
trace_ptype_value_header
);
size_t
len
=
sizeof
(
struct
trace_header
);
trace_packet_resize
(
pkt
,
len
);
pkt
->
len
=
len
;
pkt
->
data
[
0
]
=
TRACE_PTYPE_DATA
;
pkt
->
data
[
1
]
=
0
;
}
trace_packet_resize
(
pkt
,
pkt
->
len
+
entry_size
);
entry
=
pkt
->
data
+
pkt
->
len
;
pkt
->
data
[
pkt
->
len
]
=
channel
;
entry
=
pkt
->
data
+
pkt
->
len
+
1
;
switch
(
type
)
{
case
TRACE_VALUE_TYPE_BOOL
:
...
...
@@ -350,7 +350,7 @@ int trace_packet_type_set(struct trace_pkt *pkt, enum trace_value_type type)
return
0
;
}
int
trace_packet_capabilities_set
(
struct
trace_pkt
*
pkt
,
unsigned
cap
)
int
trace_packet_capabilities_set
(
struct
trace_pkt
*
pkt
,
unsigned
long
cap
)
{
size_t
len
=
sizeof
(
struct
trace_header
)
+
sizeof
(
struct
trace_ptype_capabilities
);
...
...
@@ -512,34 +512,42 @@ int trace_handle_recv(struct trace *trace)
break
;
}
case
TRACE_PTYPE_CAPABILITIES
:
{
/* ignore caps for now */
size_t
pos
=
sizeof
(
struct
trace_header
);
struct
trace_ptype_capabilities
*
ncaps
=
(
void
*
)
pkt
->
data
+
pos
;
unsigned
long
caps
=
be32toh
(
ncaps
->
capabilities
);
if
(
trace
->
handler_capabilities
)
{
trace
->
handler_capabilities
(
trace
,
caps
);
}
break
;
}
case
TRACE_PTYPE_DATA
:
{
/* ignore channel number for now (no multiplexing yet */
size_t
pos
=
sizeof
(
struct
trace_header
)
+
sizeof
(
struct
trace_ptype_value_header
);
/* ignore channel number for now (no multiplexing yet) */
size_t
pos
=
sizeof
(
struct
trace_header
);
struct
trace_ptype_value
*
v
;
uint8_t
channel
;
while
(
pos
<
pkt
->
len
)
{
v
=
(
void
*
)
pkt
->
data
+
pos
;
channel
=
v
->
channel
;
switch
(
trace
->
type
)
{
case
TRACE_VALUE_TYPE_FLOAT
:
case
TRACE_VALUE_TYPE_UINT32
:
case
TRACE_VALUE_TYPE_SINT32
:
trace
->
value
.
value
.
u32
=
be32toh
(
v
->
u
.
u32
);
pos
+=
4
;
pos
+=
4
+
1
;
break
;
case
TRACE_VALUE_TYPE_UINT16
:
case
TRACE_VALUE_TYPE_SINT16
:
trace
->
value
.
value
.
u16
=
be32toh
(
v
->
u
.
u16
);
pos
+=
2
;
pos
+=
2
+
1
;
break
;
case
TRACE_VALUE_TYPE_BOOL
:
case
TRACE_VALUE_TYPE_UINT8
:
case
TRACE_VALUE_TYPE_SINT8
:
trace
->
value
.
value
.
u8
=
v
->
u
.
u8
;
pos
+
+
;
pos
+
=
1
+
1
;
break
;
}
...
...
@@ -550,7 +558,7 @@ int trace_handle_recv(struct trace *trace)
}
trace
->
value_set
=
true
;
if
(
trace
->
handler_value
)
{
trace
->
handler_value
(
trace
,
&
trace
->
value
);
trace
->
handler_value
(
trace
,
channel
,
&
trace
->
value
);
}
}
break
;
...
...
common/trace/trace.h
View file @
74756dbf
...
...
@@ -125,11 +125,12 @@ struct trace {
char
*
name
,
enum
trace_value_type
type
,
char
*
unit
);
void
(
*
handler_type
)(
struct
trace
*
,
enum
trace_value_type
type
);
void
(
*
handler_value
)(
struct
trace
*
,
void
(
*
handler_value
)(
struct
trace
*
,
int
channel
,
struct
trace_value
*
value
);
void
(
*
handler_name
)(
struct
trace
*
,
char
*
name
);
void
(
*
handler_close
)(
struct
trace
*
);
size_t
(
*
handler_read
)(
struct
trace
*
,
void
*
buf
,
size_t
len
);
void
(
*
handler_capabilities
)(
struct
trace
*
,
unsigned
long
cap
);
void
*
private
;
};
...
...
@@ -176,8 +177,9 @@ int trace_packet_timestamp_set(struct trace_pkt *pkt,
struct
timespec
*
timestamp
);
int
trace_packet_name_set
(
struct
trace_pkt
*
pkt
,
char
*
name
);
int
trace_packet_type_set
(
struct
trace_pkt
*
pkt
,
enum
trace_value_type
type
);
int
trace_packet_value_add
(
struct
trace_pkt
*
pkt
,
struct
trace_value
*
value
,
enum
trace_value_type
type
);
int
trace_packet_capabilities_set
(
struct
trace_pkt
*
pkt
,
unsigned
cap
);
int
trace_packet_value_add
(
struct
trace_pkt
*
pkt
,
int
channel
,
struct
trace_value
*
value
,
enum
trace_value_type
type
);
int
trace_packet_capabilities_set
(
struct
trace_pkt
*
pkt
,
unsigned
long
cap
);
bool
trace_check
(
struct
trace
*
trace
);
bool
trace_fd_set
(
struct
trace
*
trace
,
fd_set
*
set
,
int
*
high
);
...
...
common/trace/trace_def.h
View file @
74756dbf
...
...
@@ -65,11 +65,8 @@ struct trace_ptype_value_type {
uint8_t
type
;
}
__packed
;
struct
trace_ptype_value_header
{
uint8_t
channel
;
}
__packed
;
struct
trace_ptype_value
{
uint8_t
channel
;
union
{
uint32_t
u32
;
uint16_t
u16
;
...
...
common/trace/trace_dump.c
View file @
74756dbf
...
...
@@ -47,7 +47,7 @@ static void handler_timestamp(struct trace *trace,
cnt
=
0
;
}
static
void
handler_value
(
struct
trace
*
trace
,
static
void
handler_value
(
struct
trace
*
trace
,
int
channel
,
struct
trace_value
*
value
)
{
cnt
++
;
...
...
common/trace/trace_dumpdiff.c
View file @
74756dbf
...
...
@@ -39,7 +39,7 @@ static void handler_interval(struct trace *trace,
}
static
void
handler_value
(
struct
trace
*
trace
,
static
void
handler_value
(
struct
trace
*
trace
,
int
channel
,
struct
trace_value
*
value
)
{
switch
(
trace
->
type
)
{
...
...
common/trace/trace_view.c
View file @
74756dbf
...
...
@@ -144,7 +144,7 @@ static void print_value(FILE *fd,
}
}
static
void
handler_value
(
struct
trace
*
trace
,
static
void
handler_value
(
struct
trace
*
trace
,
int
channel
,
struct
trace_value
*
value
)
{
struct
trace_view
*
view
;
...
...
console/console/console_httpd.c
View file @
74756dbf
...
...
@@ -385,7 +385,7 @@ static int trace_remove(struct libwebsocket *wsi)
return
0
;
}
static
void
handler_trace_value
(
struct
trace
*
trace
,
static
void
handler_trace_value
(
struct
trace
*
trace
,
int
channel
,
struct
trace_value
*
value
)
{
struct
libwebsocket
*
wsi
;
...
...
console/console/mod_websocket_dt/mod_websocket_dt.c
View file @
74756dbf
...
...
@@ -105,7 +105,7 @@ static void cleanup_command(struct plugin_private *priv)
priv
->
nr_commands
=
0
;
}
static
void
handler_trace_value
(
struct
trace
*
trace
,
static
void
handler_trace_value
(
struct
trace
*
trace
,
int
channel
,
struct
trace_value
*
value
)
{
struct
plugin_private
*
priv
;
...
...
console/console/trace_proxy.c
View file @
74756dbf
...
...
@@ -269,7 +269,7 @@ static bool timespec_mod(struct timespec *t, struct timespec *tdiv)
return
t64
%
tdiv64
;
}
static
void
server_value
(
struct
trace
*
trace
,
static
void
server_value
(
struct
trace
*
trace
,
int
channel
,
struct
trace_value
*
value
)
{
struct
trace_pkt
*
pkt
;
...
...
@@ -286,7 +286,7 @@ static void server_value(struct trace *trace,
priv
->
lastvalue
.
value
.
u32
=
value
->
value
.
u32
;
pkt
=
trace_packet_new
();
trace_packet_value_add
(
pkt
,
value
,
trace
->
type
);
trace_packet_value_add
(
pkt
,
0
,
value
,
trace
->
type
);
for
(
i
=
0
;
i
<
priv
->
nr_clients
;
i
++
)
{
bool
send
=
false
;
...
...
@@ -494,7 +494,7 @@ static void client_add(struct trace *client)
struct
trace_pkt
*
pkt
;
pkt
=
trace_packet_new
();
trace_packet_value_add
(
pkt
,
&
trace
->
value
,
trace
->
type
);
trace_packet_value_add
(
pkt
,
0
,
&
trace
->
value
,
trace
->
type
);
trace_packet_write
(
client
,
pkt
);
trace_packet_put
(
pkt
);
}
...
...
console/htdocs/trace.html
View file @
74756dbf
...
...
@@ -64,7 +64,7 @@ function load_trace(tracename)
var
trace_data
=
new
Array
();
ts
.
handler_value
=
function
(
ts
,
value
)
{
ts
.
handler_value
=
function
(
ts
,
channel
,
value
)
{
var
td
=
new
trace_value
();
td
.
set
(
value
);
trace_data
.
push
(
td
);
...
...
console/js/trace.js
View file @
74756dbf
...
...
@@ -256,7 +256,7 @@ function trace_stream()
this
.
rx_buffer
=
new
ArrayBuffer
(
0
);
this
.
handler_value
=
function
(
ts
,
value
)
{
}
this
.
handler_value
=
function
(
ts
,
channel
,
value
)
{
}
}
trace_stream
.
prototype
.
rx
=
function
(
bytearray
)
{
var
length
=
this
.
rx_buffer
.
byteLength
;
...
...
@@ -330,9 +330,11 @@ trace_stream.prototype.handle = function() {
/* ignore capabilities for now */
break
;
case
trace_ptype
.
DATA
:
j
=
2
;
/* header + channel number */
j
=
1
;
/* header + channel number */
var
datasize
;
while
(
j
<
pkt_len
)
{
while
(
j
+
1
<
pkt_len
)
{
var
channel
=
pkt
.
getUint8
(
j
);
j
++
;
switch
(
this
.
type
)
{
case
trace_value_type
.
BOOL
:
datasize
=
1
;
...
...
@@ -374,7 +376,7 @@ trace_stream.prototype.handle = function() {
}
else
{
this
.
value
.
t
.
add
(
this
.
interval
);
}
this
.
handler_value
(
this
,
this
.
value
);
this
.
handler_value
(
this
,
channel
,
this
.
value
);
j
+=
datasize
;
}
...
...
controller/controller/controller_trace.c
View file @
74756dbf
...
...
@@ -264,7 +264,7 @@ static void *controller_trace_handle(void *arg)
}
if
(
sendval
)
{
trace_packet_value_add
(
pkt
,
trace_packet_value_add
(
pkt
,
0
,
(
void
*
)
&
trace_hdl
[
i
].
ctrace
.
buffer
[
rd_pos
+
j
],
trace_hdl
[
i
].
trace
.
type
);
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment