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
21d1d47e
Commit
21d1d47e
authored
May 15, 2015
by
Jeroen Vreeken
Browse files
Some small fixes after testing with beaglebone hardware.
parent
38d1cc17
Changes
4
Hide whitespace changes
Inline
Side-by-side
controller/vesp/block_vesp_sensor_co.c
View file @
21d1d47e
...
...
@@ -137,14 +137,19 @@ static int param_set_toff(struct controller_block *block, char *param,
double
t_off
=
va_arg
(
val
,
double
);
uint16_t
ms
=
t_off
*
1000
;
vesp_command_write_eeprom
(
block
->
private
->
bus
,
if
(
vesp_command_write_eeprom
(
block
->
private
->
bus
,
block
->
private
->
address
,
VESP_SENSOR_CO_EEPROM_T_OFF_L
,
ms
&
0xff
);
vesp_command_write_eeprom
(
block
->
private
->
bus
,
ms
&
0xff
))
goto
err
;
if
(
vesp_command_write_eeprom
(
block
->
private
->
bus
,
block
->
private
->
address
,
VESP_SENSOR_CO_EEPROM_T_OFF_H
,
(
ms
>>
8
)
&
0xff
);
(
ms
>>
8
)
&
0xff
))
goto
err
;
return
0
;
err:
log_send
(
LOG_T_ERROR
,
"%s: Failed to set t_off"
,
block
->
name
);
return
-
1
;
}
static
struct
controller_block_outterm_list
outterms
[]
=
{
...
...
controller/vesp/block_vesp_tty.c
View file @
21d1d47e
...
...
@@ -79,8 +79,7 @@ static int vesp_tty_fd_recv(struct controller_block *vesp)
// log_send(LOG_T_DEBUG, "received %zd bytes", ret);
vesp_input_process
(
priv
->
bus
,
rx_buffer
,
ret
);
}
else
{
if
(
ret
==
0
||
(
ret
<
0
&&
errno
!=
EAGAIN
&&
errno
!=
EWOULDBLOCK
))
{
if
(
ret
<
0
&&
errno
!=
EAGAIN
&&
errno
!=
EWOULDBLOCK
)
{
log_send
(
LOG_T_ERROR
,
"%s: Error reading from device(%zd): %s"
,
vesp
->
name
,
ret
,
strerror
(
errno
));
...
...
controller/vesp/vesp.c
View file @
21d1d47e
...
...
@@ -195,7 +195,7 @@ int vesp_input_process_pkt(struct controller_bus *bus, void *pkt, size_t size)
struct
controller_bus_client_private
*
cpriv
=
bus
->
input_client
[
i
].
private
;
if
(
cpriv
->
address
==
address
&&
cpriv
->
command
==
response
)
{
if
(
payload_size
<=
cpriv
->
size
)
{
if
(
cpriv
->
data
&&
payload_size
<=
cpriv
->
size
)
{
memcpy
(
cpriv
->
data
,
pkt
+
2
,
payload_size
);
return
0
;
}
...
...
@@ -206,10 +206,11 @@ int vesp_input_process_pkt(struct controller_bus *bus, void *pkt, size_t size)
if
(
priv
->
response_waiting
&&
response
==
VESP_RESP_ACK
)
{
size_t
copysize
=
priv
->
response_size
;
if
(
payload_size
<
copysize
)
copysize
=
size
;
copysize
=
payload_
size
;
priv
->
response_size
=
payload_size
;
if
(
copysize
)
if
(
copysize
)
{
memcpy
(
priv
->
response_buffer
,
pkt8
+
2
,
copysize
);
}
__sync_synchronize
();
priv
->
response_waiting
=
false
;
}
...
...
@@ -347,7 +348,6 @@ ssize_t vesp_command_real(struct controller_bus *bus,
__sync_synchronize
();
priv
->
response_waiting
=
true
;
//TODO: sample-synchronize this function
if
(
vesp_output_frame
(
bus
,
tx_buffer
,
arg_size
+
2
))
goto
err
;
...
...
@@ -371,6 +371,7 @@ ssize_t vesp_command_real(struct controller_bus *bus,
timeout
.
tv_sec
--
;
}
else
timeout
.
tv_nsec
=
t_timeout
.
tv_nsec
-
t_now
.
tv_nsec
;
// log_send(LOG_T_DEBUG, "%s: attempt with timeout of %d %d", bus->name, (int)timeout.tv_sec, (int)timeout.tv_nsec);
if
(
priv
->
recv
(
bus
,
&
timeout
))
{
log_send
(
LOG_T_ERROR
,
"%s: Error while trying to get response"
,
...
...
@@ -417,17 +418,20 @@ ssize_t vesp_command(struct controller_bus *bus,
void
*
res
,
size_t
res_size
)
{
struct
command_data
data
;
int
retries
=
3
;
data
.
bus
=
bus
;
data
.
address
=
address
;
data
.
command
=
command
;
data
.
arg
=
arg
;
data
.
arg_size
=
arg_size
;
data
.
res
=
res
;
data
.
res_size
=
res_size
;
controller_sample_task
(
vesp_command_sync
,
&
data
);
do
{
data
.
bus
=
bus
;
data
.
address
=
address
;
data
.
command
=
command
;
data
.
arg
=
arg
;
data
.
arg_size
=
arg_size
;
data
.
res
=
res
;
data
.
res_size
=
res_size
;
controller_sample_task
(
vesp_command_sync
,
&
data
);
}
while
(
data
.
ret
<
0
&&
retries
--
);
return
data
.
ret
;
}
...
...
@@ -483,7 +487,7 @@ int vesp_command_write_eeprom(struct controller_bus *bus,
command
[
1
]
=
value
;
ret
=
vesp_command
(
bus
,
address
,
VESP_CMD_WRITE_EEPROM
,
command
,
2
,
NULL
,
0
);
if
(
ret
<
1
)
{
if
(
ret
<
0
)
{
log_send
(
LOG_T_ERROR
,
"%s: Could not write eeprom byte 0x%02x with 0x%02x @ device 0x%02x: %zd"
,
bus
->
name
,
offset
,
value
,
address
,
ret
);
...
...
controller/vesp/vesp_tty.ctrl
View file @
21d1d47e
...
...
@@ -4,7 +4,7 @@ trigger {
}
blocks (1.0, 0.0) {
{ "vesp_tty", "vesp", "/dev/tty
USB0
", 9600 }
{ "vesp_tty", "vesp", "/dev/tty
O1
", 9600 }
{ "vesp_sensor_co", "co_sensor", "vesp", 42 }
# { "test_output_bool", "operational" }
...
...
@@ -21,7 +21,7 @@ params {
# { "operational", "value", 4, (int) { true, true, true, true } }
{ "co_sensor", "enable", true }
{ "co_sensor", "raw",
tru
e }
{ "co_sensor", "raw",
fals
e }
{ "co_sensor", "preheat", false }
{ "co_sensor", "t_off", 0.1 }
...
...
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