Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: C12832 EthernetInterface mbed-rtos mbed ConfigFile
main.cpp
- Committer:
- dwini
- Date:
- 2015-06-14
- Revision:
- 7:23c8d34000eb
- Parent:
- 6:6cbb21cc3884
- Child:
- 8:845dfadaa70d
File content as of revision 7:23c8d34000eb:
#include "mbed.h" #include "C12832.h" #include "Log.h" #include "TcpDaemon.h" #include "StatusIndicator.h" #define TCP_SERVER_PORT 6666 #define LCD_LINE_HEIGHT 12 #define IP_ADDRESS "10.0.0.100" #define NETMASK "255.255.255.0" #define GATEWAY "10.0.0.254" Serial pc(USBTX,USBRX); DigitalOut error_led(LED1); C12832 lcd(p5, p7, p6, p8, p11); using namespace MachineVision; void setLcdServerInfo(char * ip) { lcd.cls(); lcd.locate(0,0); lcd.printf("IP: %s", ip); lcd.locate(0,14); lcd.printf("Port: %d", TCP_SERVER_PORT); } int main (void) { pc.baud(115200); lcd.cls(); lcd.locate(0,0); lcd.printf("Starting ..."); while (true) { // Setup ethernet interface EthernetInterface eth; Log::v("Bringing ethernet interface online\r\n"); // int success = eth.init(); //Use DHCP int success = eth.init(IP_ADDRESS, NETMASK, GATEWAY); if (success < 0 || eth.connect() < 0) { // Default timeout of 15 seconds Log::w("Could not bring ethernet interface online\r\n"); setLcdServerInfo("No ip address"); } else { Log::v("IP Address is %s\r\n", eth.getIPAddress()); // Set ip on LCD setLcdServerInfo(eth.getIPAddress()); // Start the daemon // PlcStatusIndicator status_indicator(p21); PlcStatusIndicator status_indicator(LED4); TcpDaemon daemon(TCP_SERVER_PORT, LED2, LED3, &status_indicator); Log::v("TCP daemon listening @ TCP_SERVER_PORT = %d\r\n", TCP_SERVER_PORT); daemon.startListening(); } pc.printf("Fail"); } }