Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RIOT
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cm-projects
RIOT
Commits
e34d46e0
Commit
e34d46e0
authored
6 years ago
by
Federico Pellegrin
Browse files
Options
Downloads
Patches
Plain Diff
drivers/at: add function to read raw data bytes from modem
parent
aa784b5e
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
drivers/at/at.c
+18
-0
18 additions, 0 deletions
drivers/at/at.c
drivers/include/at.h
+12
-0
12 additions, 0 deletions
drivers/include/at.h
tests/driver_at/main.c
+20
-0
20 additions, 0 deletions
tests/driver_at/main.c
with
50 additions
and
0 deletions
drivers/at/at.c
+
18
−
0
View file @
e34d46e0
...
@@ -58,6 +58,24 @@ void at_send_bytes(at_dev_t *dev, const char *bytes, size_t len)
...
@@ -58,6 +58,24 @@ void at_send_bytes(at_dev_t *dev, const char *bytes, size_t len)
uart_write
(
dev
->
uart
,
(
const
uint8_t
*
)
bytes
,
len
);
uart_write
(
dev
->
uart
,
(
const
uint8_t
*
)
bytes
,
len
);
}
}
ssize_t
at_recv_bytes
(
at_dev_t
*
dev
,
char
*
bytes
,
size_t
len
,
uint32_t
timeout
)
{
char
*
resp_pos
=
bytes
;
while
(
len
)
{
int
read_res
;
if
((
read_res
=
isrpipe_read_timeout
(
&
dev
->
isrpipe
,
resp_pos
,
1
,
timeout
))
==
1
)
{
resp_pos
+=
read_res
;
len
-=
read_res
;
}
else
if
(
read_res
==
-
ETIMEDOUT
)
{
break
;
}
}
return
(
resp_pos
-
bytes
);
}
int
at_send_cmd
(
at_dev_t
*
dev
,
const
char
*
command
,
uint32_t
timeout
)
int
at_send_cmd
(
at_dev_t
*
dev
,
const
char
*
command
,
uint32_t
timeout
)
{
{
size_t
cmdlen
=
strlen
(
command
);
size_t
cmdlen
=
strlen
(
command
);
...
...
This diff is collapsed.
Click to expand it.
drivers/include/at.h
+
12
−
0
View file @
e34d46e0
...
@@ -220,6 +220,18 @@ int at_expect_bytes(at_dev_t *dev, const char *bytes, uint32_t timeout);
...
@@ -220,6 +220,18 @@ int at_expect_bytes(at_dev_t *dev, const char *bytes, uint32_t timeout);
*/
*/
void
at_send_bytes
(
at_dev_t
*
dev
,
const
char
*
bytes
,
size_t
len
);
void
at_send_bytes
(
at_dev_t
*
dev
,
const
char
*
bytes
,
size_t
len
);
/**
* @brief Receive raw bytes from a device
*
* @param[in] dev device to operate on
* @param[in] bytes buffer where store received bytes
* @param[in] len maximum number of bytes to receive
* @param[in] timeout timeout (in usec) of inactivity to finish read
*
* @returns Number of bytes read, eventually zero if no bytes available
*/
ssize_t
at_recv_bytes
(
at_dev_t
*
dev
,
char
*
bytes
,
size_t
len
,
uint32_t
timeout
);
/**
/**
* @brief Send command to device
* @brief Send command to device
*
*
...
...
This diff is collapsed.
Click to expand it.
tests/driver_at/main.c
+
20
−
0
View file @
e34d46e0
...
@@ -105,6 +105,25 @@ static int send_lines(int argc, char **argv)
...
@@ -105,6 +105,25 @@ static int send_lines(int argc, char **argv)
return
0
;
return
0
;
}
}
static
int
send_recv_bytes
(
int
argc
,
char
**
argv
)
{
char
buffer
[
64
];
if
(
argc
<
3
)
{
printf
(
"Usage: %s <command> <number of bytes>
\n
"
,
argv
[
0
]);
return
1
;
}
sprintf
(
buffer
,
"%s%s"
,
argv
[
1
],
AT_SEND_EOL
);
at_send_bytes
(
&
at_dev
,
buffer
,
strlen
(
buffer
));
ssize_t
len
=
at_recv_bytes
(
&
at_dev
,
buffer
,
atoi
(
argv
[
2
]),
10
*
US_PER_SEC
);
printf
(
"Response (len=%d): %s
\n
"
,
(
int
)
len
,
buffer
);
return
0
;
}
static
int
drain
(
int
argc
,
char
**
argv
)
static
int
drain
(
int
argc
,
char
**
argv
)
{
{
(
void
)
argc
;
(
void
)
argc
;
...
@@ -228,6 +247,7 @@ static const shell_command_t shell_commands[] = {
...
@@ -228,6 +247,7 @@ static const shell_command_t shell_commands[] = {
{
"send"
,
"Send a command and wait response"
,
send
},
{
"send"
,
"Send a command and wait response"
,
send
},
{
"send_ok"
,
"Send a command and wait OK"
,
send_ok
},
{
"send_ok"
,
"Send a command and wait OK"
,
send_ok
},
{
"send_lines"
,
"Send a command and wait lines"
,
send_lines
},
{
"send_lines"
,
"Send a command and wait lines"
,
send_lines
},
{
"send_recv_bytes"
,
"Send a command and wait response as raw bytes"
,
send_recv_bytes
},
{
"drain"
,
"Drain AT device"
,
drain
},
{
"drain"
,
"Drain AT device"
,
drain
},
{
"power_on"
,
"Power on AT device"
,
power_on
},
{
"power_on"
,
"Power on AT device"
,
power_on
},
{
"power_off"
,
"Power off AT device"
,
power_off
},
{
"power_off"
,
"Power off AT device"
,
power_off
},
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment