1 / 38

Programming Microcontroller ENET (Ethernet) peripheral with MAC (Media Access Control) controller

Programming Microcontroller ENET (Ethernet) peripheral with MAC (Media Access Control) controller. 64K or 96K Byte SRAM. Enet MAC. ARM966E. CORE. w/DSP. USB 2.0FS. 96 MHz. 256K or 512K Byte Burst Flash. PFQ BC. CAN 2.0B. DMA. INTR Cntl. CLK Cntl. 32K Byte Burst Flash.

bing
Download Presentation

Programming Microcontroller ENET (Ethernet) peripheral with MAC (Media Access Control) controller

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Programming Microcontroller ENET (Ethernet) peripheral with MAC (Media Access Control) controller 64K or 96K Byte SRAM Enet MAC ARM966E CORE w/DSP USB 2.0FS 96 MHz 256K or 512K Byte Burst Flash PFQ BC CAN 2.0B DMA INTR Cntl CLK Cntl 32K Byte Burst Flash GPIO OTP Mem LVD BOD EXT. Bus JTAG ETM9 PLL RTC TIM ADC SPI I2C UART ENET with MAC controller

  2. Standard way of web communication Browser as web client Web server with data base The purpose of web application Represent the data of the server on the client Save the input of the client on the server Example of web applications Query the SBB timetable Buy books Download information about a company The classical web applications

  3. Static web pages are displayed without further processing HTML, XHTML, XML CSS Plug-Ins (Multimedia) Static web pages

  4. Client-side dynamic execution Script languages (JavaScript) Execution of Programs (Applet) Server-side dynamic execution Script languages (Perl & PHP) Execution of Programs (Servlet) Dynamic web pages

  5. Typical applications Context depending menus, input validation & calculation with formula Client-side dynamic execution

  6. Typical applications Creation of individual user web pages Server-side dynamic execution

  7. Script languages Client-side script languages JavaScript, VBSkript & Jscript Server-side script languages Perl & PHP High-level languages C, C++, C#, Visual Basic or Java Programming languages for Internet

  8. Comparison between Script & High-level Languages

  9. Languages & technologies for web site development

  10. Application examples for the embedded word Machines, automation etc. which should be accessible through Internet Purpose of the “Embedded web server” Remote maintenance (diagnostic, setting the parameters) Alarming Configuration Embedded web server

  11. ISO/OSI Model for the Client-Server communication • Transport • Network • Data link • Physical

  12. Principles of the Client-Server communication

  13. Socket is an endpoint for communication between two machines IP Address Protocol (TCP or UDP) Port number General procedure for exchanging data Build a connection using two sockets Exchange of data Close the connection Socket (Buchse / prise)

  14. TCP is a connection-oriented transport protocol Transmission Control Protocol Creating the TCP connection First, start the server Next the client must connect himself to the server Finally the data can be exchanged in both directions TCP based application

  15. socket() creates a TCP or UDP socket Server Socket SS on the server Client Socket CS on the client Specification of the used protocol (TCP or UDP) socket()

  16. bind() binds the socket with a local protocol address IP address & port number bind() is only uses by the server bind()

  17. listen() sets the server in a listening mode Maximum number of connections that will be processed simultaneously listen()

  18. accept() enables the Server to accept a connection from a client Full queue (backlog) Next connection request from the queue Empty queue New connection request from a client accept()

  19. connect() enables the client to build a connection with the server Server socket creates a new socket (newSS) Dedicated line to the requested client connect()

  20. The data are exchanged in both direction with recv() & send() recv()andsend()

  21. After successful communication The sockets newSS & CS must be closed close()

  22. UDP is minimal and non connection-oriented transport protocol User Datagram Protocol UDP-based applications

  23. Programming of client and server applications in C Application Programming Interface (API) functions of the TCP/IP- Stacks Socket programming in C

  24. Common data structure struct sockaddr { unsigned short sa_family // Address family (AF_INET) unsigned sa_data[14]; /* Protocol-specific address information */ } Data structure for AF_INET (Address Family Interactive Network System) struct sockaddr_in { unsigend short sin_family // Protocol family (PF_INET) unsigned short sin_port; // Address port (16 bits) struct in_addr sin_addr; // IP address (32 bits) } struct in_addr { NET_IP_ADDR s_addr; // IP address (32 bits) } Data structure for the protocol addresses (1)

  25. Data structure for the protocol addresses (2)

  26. Transmission of sockaddr & sockaddr_inin big endian Network byte order Conversion from the “host byte order” into “network byte order” uint32_t htonl (uint32_t hostlong); uint16_t htons (uint32_t hostshort); Help function

  27. Prototype int socket (int domain, int type, int protocol); Argument domain Application domain of the socket (PF_INET) type Behavior of the socket (SOCK_STREAM or SOCK_DGRAM) protocol IPPROTO_TCP or IPPROTO_UDP Result Success: Socket-ID Error: -1 socket()

  28. Prototype int bind (int sock_id, struct sockaddr *addr, int addrlen); Argument sock_id Result of socket() addr Information about Port number & IP address addrlen Size of addr Result Success: 0 Error: -1 bind()

  29. Prototype int listen (int sock_id, int backlog); Argument sock_id Result of socket() backlog Maximum waiting clients Result Success: 0 Error: -1 listen()

  30. Prototype int connect (int sock_id, struct sockaddr *addr, int addrlen); Argument sock_id Result of socket() addr Information about Port number & IP address of the server to connect addrlen Size of addr Result Success: 0 Error: -1 connect()

  31. Prototype int accept(int sock_id, struct sockaddr *addr_remote, int *addrlen_remote); Argument sock_id Result of socket() addr_remote Information about Port number & IP address of the client addrlen_remote Size of addr_remote Result Success: new socket ID Error: -1 accept()

  32. Prototype int recv(int newSock_id, void *buf, int *buf_len, int flags); Argument newSock_id or sock_id Result ofaccept() on server side or socket() on client side buf Buffer for the received data buf_len Length of buf flags Receive option: can be set to zero Result Success: Number of received bytes Error: -1 recv()

  33. Prototype int send(int newSock_id, void *data, int datalen, int flags); Argument newSock_id or sock_id Result ofaccept() on server side or socket() on client side data The data to transmit datalen The length of the data to transmit flags Transmit option: can be set to zero Result Success: Number of transmitted bytes Error: -1 send()

  34. Class Socket Socket (String host, int port); Stream Classes for sending or receiving the data BufferedReader InputStreamReader (ASCII  unicode) InputStream (ASCII) PrintStream (unicode  ASCII) OutputStream (ASCII) Programming in Java

  35. public void openSocket(){ try{ // replace parameters with real values sock = new Socket(Server_Address, Port); // Send without delay sock.setTcpNoDelay(true); inputStream = sock.getInputStream(); bufferedReader = new BufferedReader new InputStreamReader(inStream)); outputStream = sock.getOutputStream(); printStream = new PrintStream(outStream, true); } catch (SocketException e){ // error handling } catch (IOException e){ // error handling } } Generating a client socket in Java

  36. public void closeSocket(){ try { inputStream.close(); outputStream.close(); sock.close(); } catch (IOException e){ // error handling } } Closing the socket and the data stream

  37. public void sendData(String data){ printStream.print(data); } public void getData(){ String data; try { data = bufferedReader.readLine(); // process data } catch (IOException e){ // error handling } } Transmitting & Receiving the data

More Related