Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
W
White Rabbit Trigger Distribution
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
White Rabbit Trigger Distribution
Commits
e5af8581
Commit
e5af8581
authored
Sep 13, 2019
by
Dimitris Lampridis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[sw] add functions to detect MT IDs and rework config tool
parent
49057cee
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
363 additions
and
253 deletions
+363
-253
mock-turtle
dependencies/mock-turtle
+1
-1
libwrtd.c
software/lib/libwrtd.c
+84
-28
libwrtd.h
software/lib/libwrtd.h
+5
-1
PyWrtd.py
software/lib/python/PyWrtd.py
+187
-172
wrtd-config.py
software/tools/wrtd-config.py
+86
-51
No files found.
mock-turtle
@
add8319c
Subproject commit
b07df87ad36d963beb7d7596b3dffa4221d6bd58
Subproject commit
add8319c68770cd2dac9c10842aad8487aeb1717
software/lib/libwrtd.c
View file @
e5af8581
...
...
@@ -20,17 +20,96 @@
* @{
*/
wrtd_status
wrtd_get_node_count
(
uint32_t
*
count
)
{
int
i
;
uint32_t
dev_count
=
0
;
struct
trtl_dev
*
trtl
;
const
struct
trtl_config_rom
*
cfgrom
;
char
**
dev_list
=
trtl_list
();
if
(
!
dev_list
)
return
WRTD_ERROR_INTERNAL
;
for
(
i
=
0
;
dev_list
[
i
];
i
++
)
{
trtl
=
trtl_open
(
dev_list
[
i
]);
if
(
trtl
==
NULL
)
{
trtl_list_free
(
dev_list
);
return
WRTD_ERROR_RESOURCE_UNKNOWN
;
}
cfgrom
=
trtl_config_get
(
trtl
);
/* WRTD = 0x57525444 */
if
(
cfgrom
->
app_id
==
0x57525444
)
dev_count
++
;
trtl_close
(
trtl
);
}
trtl_list_free
(
dev_list
);
*
count
=
dev_count
;
return
WRTD_SUCCESS
;
}
wrtd_status
wrtd_get_node_id
(
uint32_t
index
,
uint32_t
*
node_id
)
{
int
i
;
uint32_t
dev_count
=
0
;
struct
trtl_dev
*
trtl
;
const
struct
trtl_config_rom
*
cfgrom
;
char
**
dev_list
=
trtl_list
();
if
(
!
dev_list
)
return
WRTD_ERROR_INTERNAL
;
*
node_id
=
0
;
for
(
i
=
0
;
dev_list
[
i
];
i
++
)
{
trtl
=
trtl_open
(
dev_list
[
i
]);
if
(
trtl
==
NULL
)
{
trtl_list_free
(
dev_list
);
return
WRTD_ERROR_RESOURCE_UNKNOWN
;
}
cfgrom
=
trtl_config_get
(
trtl
);
/* WRTD = 0x57525444 */
if
(
cfgrom
->
app_id
==
0x57525444
)
dev_count
++
;
if
(
dev_count
==
index
)
{
char
*
eptr
;
/* expecting string in the form of "trtl-xxxx, where
xxxx is a hex integer */
*
node_id
=
strtoul
(
dev_list
[
i
]
+
5
,
&
eptr
,
16
);
if
(
*
eptr
!=
0
)
{
trtl_list_free
(
dev_list
);
trtl_close
(
trtl
);
return
WRTD_ERROR_INTERNAL
;
}
}
trtl_close
(
trtl
);
}
trtl_list_free
(
dev_list
);
if
(
*
node_id
==
0
)
return
WRTD_ERROR_RESOURCE_UNKNOWN
;
return
WRTD_SUCCESS
;
}
/**
* Initialize the WRTD Node and obtain the WRTD device token.
*
* @param[in] resource_name Underlying MockTurtle device ID in
* the form of **MTxxx** or **trtl-xxxx**.
* @param[in] node_id WRTD Node ID
* @param[in] reset Reserved for future use.
* @param[in] options_str Reserved for future use.
* @param[out] wrtd Pointer to WRTD device token.
* @return #wrtd_status
*/
wrtd_status
wrtd_init
(
const
char
*
resource_name
,
wrtd_status
wrtd_init
(
uint32_t
node_id
,
bool
reset
,
const
char
*
options_str
,
wrtd_dev
**
wrtd
)
...
...
@@ -41,35 +120,12 @@ wrtd_status wrtd_init(const char *resource_name,
struct
wrtd_config_msg
msg
;
wrtd_status
status
;
static
int
initialized
;
/* In case of error... */
*
wrtd
=
NULL
;
/* Initialize (only once).*/
if
(
!
initialized
)
{
initialized
=
1
;
trtl_init
();
}
trtl
=
trtl_open_by_id
(
node_id
);
/* Resource is MTxxx where xxx is the mock-turtle device id. */
if
(
resource_name
[
0
]
==
'M'
&&
resource_name
[
1
]
==
'T'
)
{
unsigned
long
dev_id
;
char
*
eptr
;
dev_id
=
strtoul
(
resource_name
+
2
,
&
eptr
,
0
);
if
(
*
eptr
!=
0
)
{
/* Invalid characters. */
return
WRTD_ERROR_RESOURCE_UNKNOWN
;
}
trtl
=
trtl_open_by_id
(
dev_id
);
}
else
if
(
strncmp
(
resource_name
,
"trtl-"
,
5
)
==
0
)
{
trtl
=
trtl_open
(
resource_name
);
}
else
{
return
WRTD_ERROR_RESOURCE_UNKNOWN
;
}
if
(
trtl
==
NULL
)
if
(
trtl
==
NULL
)
return
WRTD_ERROR_RESOURCE_UNKNOWN
;
wrtd_dev
*
res
;
...
...
software/lib/libwrtd.h
View file @
e5af8581
...
...
@@ -242,7 +242,11 @@ typedef enum wrtd_attr {
/* Initialisation */
wrtd_status
wrtd_init
(
const
char
*
resource_name
,
wrtd_status
wrtd_get_node_count
(
uint32_t
*
count
);
wrtd_status
wrtd_get_node_id
(
uint32_t
index
,
uint32_t
*
node_id
);
wrtd_status
wrtd_init
(
uint32_t
node_id
,
bool
reset
,
const
char
*
options_str
,
wrtd_dev
**
wrtd
);
...
...
software/lib/python/PyWrtd.py
View file @
e5af8581
This diff is collapsed.
Click to expand it.
software/tools/wrtd-config.py
View file @
e5af8581
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
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