![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Modularizando o src
Dependencies: EALib EthernetInterface_vz mbed-rtos mbed
Fork of header_main_colinas_V0-20-09-14 by
power_source_monitoring.cpp@132:05cd37f7e007, 2015-09-01 (annotated)
- Committer:
- klauss
- Date:
- Tue Sep 01 17:21:11 2015 +0000
- Revision:
- 132:05cd37f7e007
- Parent:
- 128:3ae1c74773a8
Substitui??o de; send_msg -> vz_printf; debug_msg -> vz_debug
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
klauss | 128:3ae1c74773a8 | 1 | #include "power_source_monitoring.h" |
klauss | 128:3ae1c74773a8 | 2 | |
klauss | 132:05cd37f7e007 | 3 | Timer power_source_timer; |
klauss | 132:05cd37f7e007 | 4 | |
klauss | 132:05cd37f7e007 | 5 | DigitalIn pwr_src_in ( p25, PullDown ); |
klauss | 132:05cd37f7e007 | 6 | //DigitalIn pwr_src_in ( p25, PullUp ); |
klauss | 132:05cd37f7e007 | 7 | |
klauss | 132:05cd37f7e007 | 8 | UDPSocket power_source_client; |
klauss | 132:05cd37f7e007 | 9 | |
klauss | 128:3ae1c74773a8 | 10 | Endpoint pwr_src_server; |
klauss | 132:05cd37f7e007 | 11 | |
klauss | 132:05cd37f7e007 | 12 | uint8_t power_source_status = 0; |
klauss | 128:3ae1c74773a8 | 13 | |
klauss | 128:3ae1c74773a8 | 14 | /* Inicializacao da comunicacao UDP com o servidor para monitoramento de fonte de alimentacao */ |
klauss | 132:05cd37f7e007 | 15 | int init_power_source () { |
klauss | 132:05cd37f7e007 | 16 | char server_ip [ 16 ]; |
klauss | 128:3ae1c74773a8 | 17 | |
klauss | 128:3ae1c74773a8 | 18 | /* Inicializacao do timer de leitura de fonte de alimentacao */ |
klauss | 132:05cd37f7e007 | 19 | power_source_timer.stop (); |
klauss | 132:05cd37f7e007 | 20 | power_source_timer.reset (); |
klauss | 128:3ae1c74773a8 | 21 | |
klauss | 128:3ae1c74773a8 | 22 | /* Inicializacao do comunicacao UDP */ |
klauss | 132:05cd37f7e007 | 23 | power_source_client.set_blocking( false, 0 ); |
klauss | 132:05cd37f7e007 | 24 | power_source_client.bind ( u16_POWER_SOURCE_PORT ); |
klauss | 132:05cd37f7e007 | 25 | |
klauss | 128:3ae1c74773a8 | 26 | // Criar depois, se quiser, arquivo para PWR_SRC_PORT |
klauss | 132:05cd37f7e007 | 27 | cm -> get_server_ip ( server_ip ); |
klauss | 132:05cd37f7e007 | 28 | pwr_src_server.set_address ( server_ip , u16_POWER_SOURCE_PORT ); |
klauss | 128:3ae1c74773a8 | 29 | |
klauss | 132:05cd37f7e007 | 30 | power_source_timer.start (); |
klauss | 132:05cd37f7e007 | 31 | |
klauss | 132:05cd37f7e007 | 32 | return ( 0 ); |
klauss | 132:05cd37f7e007 | 33 | } |
klauss | 132:05cd37f7e007 | 34 | |
klauss | 132:05cd37f7e007 | 35 | int |
klauss | 132:05cd37f7e007 | 36 | end_power_source ( void ) |
klauss | 132:05cd37f7e007 | 37 | { |
klauss | 132:05cd37f7e007 | 38 | power_source_client.close (); |
klauss | 132:05cd37f7e007 | 39 | |
klauss | 132:05cd37f7e007 | 40 | return ( 0 ); |
klauss | 132:05cd37f7e007 | 41 | } |
klauss | 132:05cd37f7e007 | 42 | |
klauss | 132:05cd37f7e007 | 43 | int |
klauss | 132:05cd37f7e007 | 44 | reconnect_power_source ( void ) |
klauss | 132:05cd37f7e007 | 45 | { |
klauss | 132:05cd37f7e007 | 46 | end_power_source (); |
klauss | 132:05cd37f7e007 | 47 | init_power_source (); |
klauss | 128:3ae1c74773a8 | 48 | |
klauss | 128:3ae1c74773a8 | 49 | return ( 0 ); |
klauss | 128:3ae1c74773a8 | 50 | } |