Forum Discussion
Ethernet Interface
Hi,
I have a system (a probe) that is currently sending/receiving data from the PC terminal using a UART(RS232) connection. This was easy to configure/program, and the hardware was also easy to make up. However, I wish to upgrade to an Ethernet Interface to improve the speed of the data transfer. I wish to transmit/receive 16-bits of data in one go, I have already done the Web Server and Simple Socket tutorials, but they are way to complex for my needs....is there no equivalent for printf() / getchar() when uning the Ethernet... Thanks in advance... Kushan.16 Replies
- Altera_Forum
Honored Contributor
--- Quote Start --- Could you post some code for opening a TCP socket...I have successfully completed the Simple Socket Server Tutorial, and it runs, so what would the next step be? --- Quote End --- You can open a socket using a socket() call. This opens socket for both UDP and TCP/IP. Beej's Guide To Network Programming (Using Internet Sockets) ( http://www.beej.us/guide/bgnet/ ) is the best quick-start resource for socket programming. Sample codes (for both client and server) and essential differences between UDP and TCP/IP programming are also given here. - Altera_Forum
Honored Contributor
Could you post some code for opening a TCP socket...I have successfully completed the Simple Socket Server Tutorial, and it runs, so what would the next step be?
- Altera_Forum
Honored Contributor
I'm not sure this is the way to go... If you use Ethernet as a raw transport medium you would need to write your own PC driver to replace the TCP/IP stack with your own and recover the raw Ethernet data. Sounds really difficult.
It's really simpler to use TCP/IP on your NIOS system, and the socket API is not that difficult to use. Have a deeper look at the simple socket server example. Once you open a TCP socket it's almost as easy to use as a character I/O. - Altera_Forum
Honored Contributor
--- Quote Start --- 2 - If you don't need the TCP/IP protocol layers and you just wanted to use ethernet as a raw transport medium. Then you could get away from the TCP/IP stack altogether and simply write/read raw data to/from the ethernet interface. However, you would have to completely control both ends of the connection and all connection points between. Jake --- Quote End --- Any hints/tips/sample code to point me in the right direction for using the ethernet as a raw transport medium...I can't seem to get my head around the whole TCP/IP protocol. cheers, Kushan. - Altera_Forum
Honored Contributor
--- Quote Start --- Hi, I wish to transmit/receive 16-bits of data in one go, I have already done the Web Server and Simple Socket tutorials, but they are way to complex for my needs....is there no equivalent for printf() / getchar() when uning the Ethernet... Kushan. --- Quote End --- You can use Altera Host-Based File System in which you can write the entire received data in a file and can examine it later. The receive() call in socket programming gives out the data packets. - Altera_Forum
Honored Contributor
1 - What I recommend doing is spending a little time analyzing the Simple Socket Server example. Once you create a socket and it's connected to your host PC, you can transfer whatever data you like across it. You just need to understand how that connection is established and managed then doing your data transfers will be simple. You can even write your own printf and getchar wrapper functions around the socket interface if you like.
There are low level methods for accessing the socket but it would require you to do a lot more work on your end to establish and maintain the connection. Using the BSD socket calls is really the easiest way method to get up and running. 2 - If you don't need the TCP/IP protocol layers and you just wanted to use ethernet as a raw transport medium. Then you could get away from the TCP/IP stack altogether and simply write/read raw data to/from the ethernet interface. However, you would have to completely control both ends of the connection and all connection points between. Jake