Embedded Systems Development and Labs; The English Edition
(2) Transmission Layer Specific Interface Programming Methods
Network protocols can provide specific function call interfaces for higher layer/interlayer protocols/applications. Users can call the specific interfaces provided by the protocol source code to implement a fast data transfer. The Embest development board provides TFTP protocol specific interface functions. The user can use this interface to receive data from the host computer. The main interface functions are the following:
●TftpRecv(int *len) receives data. The network library automatically finishes the connection process. The maximum length of each reception is determined by “len” parameter. Before the function returns, the “len” will be changed by actual length of received data. The function returns a pointer value to the first address of data. If it returns Null, it means that a communication error has happed.
●MakeAnswer() Every time after the data has been processed, this function should be called in order to send a acknowledge signal to the host. The receiving of the ACK will allow the transmission to continue.
6.2.5 Operational Steps
(1)Prepare the Lab environment. Connect the Embest Emulator to the target board. Connect the target board UART0 to the PC serial port using the serial cable that comes with the Embest development system. Connect the network port to the hub through a network cable. Connect the network port of PC to the hub through a network cable.
(2)Set the IP address of PC as 192.192.192.x (x is within the 30-200 range). Reboot the PC to make the IP address valid.
(3)Run PC DOS window or select StartÆRun at the desktop, input the command:
arp –s 192.192.192.7 00-06-98-01-7e-8f
(4)Connect the Embest Emulator to the target board. Open the TFTP_Test.ews project file in the TFTP_Test sub directory in the sample directory. After compiling and linking, connect to the target board and download the program.
(5)Run the TFTPDown.exe on PC, input the target board address 192.192.192.7. Input the address 0x30000 at the Flash Start Address. Select the file that needs to be downloaded (bin, elf, etc. maximum 1M). Click the Download button. The program will download the file into the flash of the target board using the TFTP protocol. Success or error message will be prompted at the dialog box.
(6)Stop the target board run the Embest IDE. Open the Memory window and display the content from address 0x30000. Check if the data in flash is consistent with the downloaded file.
(7)After understanding the functionality of the lab, finish the Lab exercises.
Sample Programs void Tftp_Test()
{
char* pData;
unsigned long write_addr;