Home
AN406 - Will That Be Serial or Ethernet?
Contents
1. Cee oon a a E 8 g A amp Back Forward Stop Refresh Home Search Favorites Media History Mail Print Address http 10 10 6 103 Z WORLD RAGE ee Serial to Ethernet 2 Application Kit Network MESERON SERIO Network SERO SER1 IP Address fi0106100 Gateway hoosi Netmask 255 255 255 0 DHCP Disabled z Keepalive Enabled gt Alivetime fizo Nagle Enabled 7 Submit Recall Restart File Edit View Favorites Tools Help e Back Forward Stop Refresh Home a m S 9j 5 Mal Prit Edt Search Favorites Media History Address http 10 10 6 103 ser0 zhtml Network SERO SER1 Port Baudrate Remote Port Local Port Serial Mode Databits Parity Flow Control TCP Mode Flush Remote Address Submit Z WORLD RACE aes Serial to Ethernet 2 Application Kit Network sero SERED Enabled x 15200 bps 1231 RS232 7 None Si Disabled x Listen 7 Disabled gt yagan 0 0 0 Recall Restart 022 0099 Rev D 16 Serial Console You can also bring up the serial console on Serial Port A by connecting the DIAG connector on the pro gramming cable to the programming header on the RCM3700 the other end of the programming cable is still connected to the COM port on your PC Open a Hyperterminal session Start gt Accessories gt Communications Select the COM port the programming cable is connected to and set the default serial parameters
2. AN406 Will That Be Serial or Ethernet Introduction Ethernet networks and the Internet are rapidly becoming the preferred means for connecting remote devices and Web browsers provide an easy access to display data and otherwise interface with the remote devices Regardless of whether you re collecting data automatically or are looking at a remote device of one kind or another you re going to eventually have to connect your device to a PC or other terminal In many cases that connection will likely be through a network of some kind A serial RS 232 or RS 485 network may suffice for short distances but you ll have to use an Ethernet Internet network for long distance or world wide connectivity Ethernet Internet connections will also help you view and control multiple devices when all you have is one PC or terminal with a limited number of COM ports or maybe just a notebook with one USB port Then too the device sending all the data might just have a single RS 232 port to save on costs and you will have yet another reason to convert the signal protocols Rabbit Semiconductor s Multi Port Serial to Ethernet Application Kit provides you with the proven hardware and software you need to convert between serial and Ethernet protocols or vice versa The software in the Multi Port Serial to Ethernet Application Kit is pretty straightforward It initializes the RCM3700 sets up the TCP IP protocol stack and serial ports and waits for a ne
3. 8 Parity None Stop bits 1 Flow control Hardware With the Hyperterminal client active click on the Hyperterminal window appearing on your PC desktop and the Telnet session you started before still running anything you type on your keyboard will be echoed back by the Rabbit and will appear in the Telnet window With the Telnet window active click on the Telnet window appearing on your PC desktop anything you type on your keyboard will be echoed back by the Rabbit and will appear in the Hyperterminal window Note that you will not see what you are typing in the active window unless you have enabled the local echo 022 0099 Rev D 9 S2E_ZCONSOLE C This sample program demonstrates how to perform serial and network configuration using a console based on the Dynamic C ZCONSOLE LIB library The console functionality can be embedded in an application to allow network and serial configurations to be changed without having to rewrite and recompile the whole application The console functionality is wrapped by the Dynamic C S2E_ZCONSOLE LIB library which interfaces directly with the Dynamic C SER2ETH LIB library More information about the ZCONSOLE LIB library and settings and structures can be found in Chapter 17 of the TCP IP User s Manual Before you run this program place one of the jumpers supplied with the spare parts in the Application Kit between the Serial Port D Rx and Tx lines on header J2 on the
4. ACTIVE OPENor S2E ACTIVE LISTEN S2E RS232o0rS2E RS485 For example a params string could be S2E_DATABITS 8 S2EPARITY_NONE S2E THREE WIRE S2E ACTIVE LISTEN S2E RS232 S2E DEF PARAM sets up params using S2E DATABITS 8 S2EPARITY NONE S2E THREE WIRE S2E ACTIVE LISTEN S2E RS232 RETURN VALUE 1 if successful 1 if there was a COM port initialization error SEE ALSO s2e init s2e set485 s2e enable s2e disable s2e tick s2e savesettings s2e recallsettings s2e setnetparams 022 0099 Rev D 24 Initialize the serial to Ethernet library RETURN VALUE None SEE ALSO s2e setnetparams s2e setup s2e enable s2e disable s2e tick s2e savesettings s2e recallsettings Sets the network parameters used in the Serial to Ethernet software PARAMETERS ip addr is the resolved IP address netmask is the resolved netmask gateway is the resolved gateway address lport is the resolved address for the local port dhcp OnOff is the DHCP status 0 for OFF 1 for ON keepalive OnOff is the KeepAlive on off 0 for OFF 1 for ON keepalive Time is the KeepAlive time in seconds dhcp OnOff is the Nagle algorithm on off 0 for OFF 1 for ON RETURN VALUE None SEE ALSO s2e init s2e setup s2e enable s2e disable s2e tick s2e savesettings s2e recallsettings Brings up the network interface using the data specified by the s2e_setparams function call and sets up the serial ports RETURN VALUE 1 when complet
5. RCM3700 2 S28 Prototyping Board Once this sample program is running start a Telnet session Start gt J2 eee cc Run gt telnet 10 10 6 100 to the default TCP socket 23 The console will be oqa displayed in the Telnet window Type help lt return gt to display the available commands i Available Commands type help lt command gt for more info ECHO Turn on or off echoing of characters HELP This help Screen LOGI N NAME Change or set login name LOGIN PASSWORD Change or set password SETX Set Serial port attributes Replace x with serial port SETNET Set network settings SHOW SERX Show serial port settings Replace x with serial port SHOW NET Show network settings STORE Store settings RECALL Undo unstored changes RESTART Restart device EXIT Exit console LOGOUT Logout The x serial ports in the SETX and SHOW SERX commands correspond to x 0 Serial Port D and x 1 Serial Port E Type help lt command gt lt c lt return gt for more information about the ECHO SETNET and SETX com mands The type of additional information is listed here for the various commands e ECHO echo off will stop the characters being input from being echoed back e SET x is used in the context set x lt parameter gt The following parameters can be set status on of f enable or disable port baudrate lt number gt baud rate Sermode rs232 rs485 select RS 232 or RS 485 databits 8 7 se
6. Serial to Ethernet Application Kit has two sample programs S2E HEX CandS2E DVM C to illustrate this functionality The function prototype of the serial handler in the S2E HEX C sample program looks like this int serhandler hex S2EControl ctrl The serhandler hex function takes a pointer to an S2EControl structure which provides the user context and access to the serial to Ethernet connection After a TCP connection has been established the userstate variable gets initialized to zero This value is intended to be used by the handler to track any state information There is also a void member userdata which can be used for an extended data structure if more state information is needed The userdata member is initialized to zero at the begin ning of the program by the s2e_ init function call and unlike userdata does not get reinitialized on each new connection The S2EControl structure provides members to access the TCP and serial sides of the connection The sock member can be used with the TCP functions as outlined in the TCP IP User s Manual The struc ture also has function pointers to the underlying serial routines as outlined in the following table Each of the function pointers maps directly to functions in the Dynamic C RS232 LIB library Member Maps to open serXopen close serXclose rdFlush serXrdFlush wrFlush serXwrFlush rdUsed serXrdUsed read serXread peek serXpee
7. define BAUDRATE line the final parameter the serial port parameter is configured via a logical combination of the five macros replace S2E RS232 withS2E RS485 if you are configuring Serial Port E for RS 485 022 0099 Rev D 3 Call s2e_set485 if you are using Serial Port E for RS 485 int s2e set485 S2E SERPORT E ser485Tx ser485Rx When using RS 485 you will have to include code to enable and disable the RS 485 transmitter with ser485Tx and ser485Rx as shown in the S2E SAMPLE C sample program Now use the s2e_setnetparams function call to set up the network parameters s2e setnetparams resolve DEFAULT IP ADDRESS resolve DEFAULT NETMASK resolve DEFAULT GATEWAY DEFAULT DHCP STATE DEFAULT KEEPALIVE DEFAULT ALIVETIME DEFAULT USE NAGLE Remember to call s2e_ init to initialize the SER2ZETH LIB library s2e init Although ASCII data encoding is the most common protocol some serial devices use binary data or differ ent character encoding This means the data that are sent over the serial port might not be readily readable via the Telnet or Hyperterminal utilities on your PC However the serial data will still be handled just fine by the RCM3700 as long as a compatible device is available at the other end to receive and display the data PC Configuration This section shows how to configure your PC or notebook to run the sample programs If the PC or note book used with the RCM3700 is connected to a ne
8. lines of Serial Ports D and E together via jumpers on header J2 of the RCM3700 Prototyping Board The jumpers are not required to simply view or use the Web console or the serial console The Web browser sample program uses both Serial Port A and the standard Telnet port 23 as a console Serial Ports D and E are associated with TCP ports 1230 and 1231 The standard Telnet port 23 is used as a remote console No RabbitWeb Module tInstall BIN File An already compiled binary image is available in the SAMPLES Serial2Ethernet 2 RabbitWeb folder for users who do not have the Dynamic C RabbitWeb module installed or do not want to compile the S2E RABBITWEB C sample program at this time Close Dynamic C if you have it running on your desk top but leave the programming cable in place between the programming header of the RCM3700 and your PC COM port The crossover Ethernet should be in place between the RJ 45 jack on the RCM3700 and the Ethernet card on your PC Load the S2E_RABBITWEB BIN file with the Rabbit Field Utility which is available as part of your Dynamic C installation Choose Flash Image x Flash Image in the Dynamic C Utilities folder Locate this folder via Fie Location wabbiweb S2E_RABEITWEBbn Windows Explorer or My Computer and double click on Rfu exe to launch the Rabbit Field Utility Select File gt ox Cancel Hep Load Flash Image and click on the beside the dialog box to browse for the S2E_RABBITWEB BIN f
9. screen Note that two of the lines in the cable opposite the colored side are not connected within the 10 pin connector Serial Port C Serial Port E J2 J2 J2 Open a Hyperterminal session Start gt Accessories gt Communications Select the COM port the cable is connected to and set the default serial parameters Bits per second 115200 Data bits 8 Parity None Stop bits 1 Flow control None With the Hyperterminal client active click on the Hyperterminal window appearing on your PC desktop and the Telnet session to port 1232 still running anything you type on your keyboard will be echoed back by the Rabbit and will appear in the Telnet window With the Telnet window active click on the Telnet window appearing on your PC desktop anything you type on your keyboard will be echoed back by the Rabbit and will appear in the Hyperterminal window Note that you will not see what you are typing in the active window unless you have enabled the local echo You can repeat this activity via the long cable by connecting Serial Port C or Serial Port E from header J2 to the cable 10 pin connector with hookup wire to the cable 10 pin connector positions shown in the above diagram You can also try out Serial Port E as an RS 485 serial port by jumpering pins 3 5 and pins 4 6 on header JP2 on the Prototyping Board before you recom pile and run the sample program with the programmin
10. types of data streams The functionality of the serial handler is documented in the appendix Before you run this program place one of the jumpers supplied with the spare parts in the Application Kit between the Serial Port D Rx and Tx lines pins 3 and 5 on header 292 J2 on the RCM3700 Prototyping Board Be careful not to confuse header J2 with Ile a nearby header JP2 Once this sample program is running start a Telnet session Start aqqu9 gt Run gt telnet 10 10 6 100 with the default Telnet socket 23 Once the inet Telnet client is active click on the Telnet window appearing on your PC desktop any thing you type on your keyboard will have its hex equivalent echoed back by the Rabbit and will appear in the Telnet window To convince yourself that the RCM3700 is indeed doing the serial to Ethernet conver sion you can remove the jumper between the Serial Port D Rx and Tx lines on header J2 on the RCM3700 Prototyping Board and you will no longer see the hex equivalent from your keyboard in the Telnet window Instead of using a jumper across the Serial Port D Rx and Tx lines on header J2 on the RCM3700 Prototyping Board you may use the long 10 pin header Colored to DB9 cable Part No 540 0085 to connect header J2 to your PC COM edge port remember to disconnect the programming cable if you only have one COM port Line up the colored edge of the cable with pin 1 on header J2 as shown in the diagram pin
11. 1 is indicated by a small square on the Prototyping Board silkscreen Note that two of the lines in the cable oppo site the colored side are not connected within the 10 pin connector J2 GND m o TxDjo o RxD o o TxE o o GND o o Open a Hyperterminal session Start gt Accessories gt Communica tions Select the PC COM port the cable is connected to and set the default serial parameters Bits per second 57600 Data bits 8 Parity None Stop bits 1 Flow control None With the Hyperterminal client active click on the Hyperterminal window appearing on your PC desktop and the Telnet session you started before still running anything you type on your keyboard will have its hex equivalent transferred by the Rabbit and will appear in the Telnet window With the Telnet client active click on the Telnet window appearing on your PC desktop anything you type on your keyboard will be transferred by the Rabbit without a hex conversion and will appear in the Hyperterminal window Note that you will not see what you are typing in the active window unless you have enabled the local echo To select a different serial port change the S2E_USEPORT_D and S2E_SERD_BUFSIZE macros in the sample program To select a different TCP IP port change the TCPPORT macro in the sample program Note that the long 10 pin header to DB9 cable Part No 540 0085 only provides a serial connectio
12. 34 above define TCPCONFIG 6 Remember to use the SER2ETH LIB library use ser2eth 1lib The brdInit function call initializes the Rabbit microprocessor brdInit Initialize Rabbit The sock init function call initializes the Dynamic C DCRTCP LIB library used for TCP IP sock init Initialize dertcp library 022 0099 Rev D 18 Set bit 5 low on Parallel Port E of the Rabbit 3000 microprocessor to enable the RS 232 chip on the RCM700 Proto typing Board i BOARD TYPE gt RCM3600A amp amp _BOARD TYPE _ A Ox1FFF BitWrPortI PEDR amp PEDRShadow 0 5 endif Initialize the SER2ETH LIB library s2e init Set up each serial port s2e setup SERIALPORT TCPPORT 0 OL BAUDRATE S2E DATABITS 8 S2E PARITY NONE S2E THREE WIRE S2E ACTIVE LISTEN S2E RS232 Set up the global network parameters s2e setnetparams resolve DEFAULT IP ADDRESS resolve DEFAULT NETMASK resolve DEFAULT GATEWAY DEFAULT DHCP STATE DEFAULT KEEPALIVE DEFAULT ALIVETIME DEFAULT USE NAGLE The TCP interface is brought up using the parameters stored in flash memory s2e connect The sample program now loops until the interface comes up and then loops continuously to perform the serial to Ethernet conversions 022 0099 Rev D 19 Serial Handler A callback is provided with the serial to Ethernet software to allow you to interpret data before sending it out the TCP connection The Multi Port
13. Assigns a serial port to an IP port This function must be the first serial to Ethernet function used After the setup is completed this function will also enable the serial port for Ethernet connectivity PARAMETERS serport is the serial port to set up use the S2E_ SERPORT_X macro where X A to F corresponding to Serial Port A to Serial Port F for this parameter 1_port is the TCP address of the local port the default is 23 for Telnet connections 1230 1233 are also used in the sample programs In the ACTIVE LISTEN mode the port listens for a connection at the TCP address and in the ACTIVE OPEN mode the port is used to send data ip port is the TCP address of the remote port to listen to in the ACTIVE_ LISTEN mode use 0 to listen to all the remote ports in the ACTIVE OPEN mode ip_port is the TCP address of the remote port to connect to rem address is the IP address of the remote port an address is required if the ACTIVE OPEN macro was set with the ip port parameter a value of 0 can be passed if the ACTIVE LISTEN macro was set with the ip port parameter and the remote IP address is required baudrate is the baud rate to use add L to the baud rate to indicate to Dynamic C that this is a Long variable params are the serial port parameters based on a logical combination of the following macros S2E DATABITS 8o0rS2E DATABITS 7 S2E PARITY NONE S2E PARITY ODD S2E PARITY EVEN orS2E STOPBITS 2 S2E THREE WIREor S2E FIVE WIRE S2E
14. Bits per second 57600 Data bits 8 Parity None Stop bits 1 Flow control None With the Hyperterminal client active click on the Hyperterminal window appearing on your PC desktop you should see the serial console that we looked at in the S2E_ZCONSOLE C sample program You may have to press lt return gt or type help lt return gt to start the serial console Comparing Consoles What you save in one console is reflected in what is displayed in the other console For example try changing the network IP address from 10 10 6 100 to 10 10 6 103 in the Network screen of the Web console After you press the Submit button the Store button which comes up after you press the Submit button and the Restart button the Web browser will display Restarting You will to enter the new URL http 10 10 6 103 in the Web browser s Address line to view the changed network settings or you can type Show net lt return gt to view them using the serial console Now let s change things back using the serial console Type setnet ip 10 10 6 100 lt return gt in the serial console followed by store lt return gt and restart lt return gt and refresh your Web browser with the URL http 10 10 6 100 in the Web browser s Address line In summary we have shown three ways that network and serial parameters can be viewed and configured e Via a Web browser as shown in the S2E RABBITWEB C sample program e Via Hyperterminal through a serial interface
15. Board must be jumpered to set up Serial Port E as an RS 232 serial port iji Once this sample program is running start three Telnet sessions Start gt Run gt telnet 10 10 6 100 1231 Start gt Run gt telnet 10 10 6 100 1233 to the IP address 10 10 6 100 With a Telnet client active click on one of the Telnet windows appearing on your PC desktop anything you type on your keyboard will be echoed back RxC TxC Q Z x Ore ee LECE aqoy oO p gt TxD RxD GND o a 022 0099 Rev D 7 by the Rabbit and will appear in that Telnet window To convince yourself that the RCM3700 is indeed doing the serial to Ethernet conversion you can remove the jumper for the Rx and Tx lines on header J2 for the serial port you are using and you will no longer see what you type on your keyboard in the Telnet window You may also try connecting the Tx line from one serial port to the Rx line of another serial port Instead of using jumpers across the three serial port Rx and Tx lines on header J2 on the RCM3700 Proto typing Board you may use the long 10 pin header to DB9 cable Part No 540 0085 Because the PC COM port only has one set of Tx and Rx lines you can only view Serial Port D when you connect the cable directly from header J2 to your PC COM port Line up the colored edge of the cable with pin 1 on header J2 as shown in the diagram pin 1 is indicated by a small square on the Prototyping Board silk
16. M3700 are used by the sample programs with this Application Kit Serial Port Default Use Alternate Use Sample Programs Serial Port A Programming port 3 wire RS 232 S2E RABBITWEB C Serial Port C 3 wire RS 232 RTS CTS S2E SAMPLE C S2E BASIC 5WIRE C Serial Port D 3 wire RS 232 5 wire RS 232 S2E BASIC C S2E SAMPLE C S2E BASIC 5WIRE C S2E TEMP SAMPLE C S2E_ ZCONSOLE C S2E RABBITWEB C Serial Port E RS 485 3 wire RS 232 S2E SAMPLE C S2E RABBITWEB C 022 0099 Rev D Serial Port E on the RCM3700 may be configured in hardware as either an RS 232 or an RS 485 serial port when the RCM3700 is used with the Prototyping Board RCM3700 Prototyping Board The hardware configuration details for doing JP2 r oo oi oo oi this via header JP2 on the RCM3700 Prototyping Board are shown in the RCM3700 User s Manual which is available on the Dynamic C CD ROM Hay sas RS 232 RS 485 When Serial Port E is configured as an RS 232 serial port its signals are available on header J2 the RS 232 header on the RCM3700 Prototyping Board When Serial Port E is configured as an RS 485 serial port its signals are available on header J1 the RS 485 connector on the RCM3700 Prototyping Board Serial Ports C and D are also available on header J2 the RS 232 header on the RCM3700 Prototyping Board Serial Ports C and D are RS 232 only and must be
17. already configure the RCM3700 with a default TCPCONFIG 6 macro which allows specific IP address netmask gateway and other network parameters to be set at runtime This sample code shows these network configurations which are used by the parameters in the s2e_ setnetparams function call define define define define define define define define define define TCPCONFIG 6 TCPPORT 23 23 1230 1233 used in the sample programs 23 is the default Telnet TCP port BAUDRATE 115200L L identifies baud rate as a long variable DEFAULT IP ADDRESS DEFAULT GATEWAY 10 10 6 DEFAULT NETMASK 255 255 DEFAULT KEEPALIVE 1 DEFAULT ALIVETIME 120 DEFAULT DHCP STATE 0 DEFAULT USE NAGLE 1 10 10 6 100 1 255 0 0 KeepAlive Off 1 On Delay Between KeepAlive pings 0 DHCP Off 1 On 1 Use Nagle 0 Do not use Nagle Change the network settings to configure the RCM3700 with your own Ethernet settings only if that is necessary to run the sample programs There are some other standard configurations for TCPCONFTIG that let you select different features such as DHCP Their values are documented at the top of the TCP_ CONFIG LIB library in the LIB TCPIP directory More information is available in the Dynamic C TCP IP User s Manual Serial Port Configuration In addition to configuring the network connections you can also configure the serial ports Four serial ports from the RC
18. as shown in the S2E_ RABBITWEB C sample program e Via Telnet through an Ethernet interface as shown in the S2E_ZCONSOLE C sample program 022 0099 Rev D 17 Appendix Software Reference Sample Program Let s examine some of the code in the S2E_ BASIC C sample program First the program settings used at startup are defined These settings are using by the parameters in the s2e setup andthe s2e setnetparams function calls define TCPPORT 23 Default telnet service port define BAUDRATE 115200 define DEFAULT IP ADDRESS 10 10 6 100 IP Address define DEFAULT GATEWAY 10 10 6 1 Gateway define DEFAULT NETMASK 255 255 255 0 Netmask define DEFAULT KEEPALIVE 1 0 KeepAlive Off 1 On define DEFAULT ALIVETIME 120 Delay Between KeepAlive pings define DEFAULT DHCP STATE 0 0 Dhep Off 1 On define DEFAULT USE NAGLE 1 1 Use Nagle 0 No use Nagle define SERIALPORT S2E SERPORT D Select Serial Port D Next the SER2ETH LIB library settings are defined define S2E USEPORT D Enable Serial Port D define S2E SERD BUFSIZE 511 Serial Port D buffer size define S2E ACKNOWLEDGE Acknowledge an established connection define S2E DEBUG For single stepping through library define S2E VERBOSE For displaying handler status Now select a setting for the TCPCONFIG LIB library TCPCONFIG 6 allows the network interface to be set up manually using the macros in lines 27
19. configured in software for RS 232 Configure Serial Ports in Software One of the first steps is to use the serial to Ethernet library use SER2ETH LIB Now define the serial port use via configuration macros X here represents Serial Port A to Serial Port F define S2E USEPORT X Enable Serial Port X X A to F define S2E SERX BUFSIZE N Serial Port X buffer size default 255 define S2E SERX USE HANDSHAKING Serial Port X flow control if used These are typical settings for an RS 232 serial port e 8 data bits e stop bit e No parity e No flow control one serial port required or Flow control on two serial ports required e 115200 baud Use the s2e_ setup function call from the Dynamic C SER2ETH LIB library to set up each serial port s2e setup S2E SERPORT X LOCALTCP REMOTETCP REMOTEIP BAUDRATE S2E DATABITS 8 S2E PARITY NONE S2E THREE WIRE S2E ACTIVE LISTEN S2E RS232 where S2E SERPORT X is the serial port being set up X A to F LOCALTCP is the TCP address of the local port set 23 as a default Telnet address 1230 1233 are also used in the sample programs REMOTETCP is the TCP address of the remote port use 0 to listen to all remote ports REMOTETP is the IP address of the remote port use 0 to listen to all remote ports always add L to the number to indicate to Dynamic C that this is a long type of variable BAUDRATE is the baud rate to use as declared earlier in the
20. ct Disables the serial port for serial to Ethernet connectivity The serial port must be first set up using the s2e_ setup function call PARAMETER serport is the serial port to enable use the S2E_ SERPORT_X macro where X A to F corresponding to Serial Port A to Serial Port F for this parameter RETURN VALUE 1 if successful 1 if an error occurred SEE ALSO s2e setup s2e enable s2e tick s2e savesettings s2e recallsettings s2e init s2e printsetup s2e setnetparams s2e connect This serial to Ethernet handler function must be called periodically from the application This function copies the data to and from the serial and TCP connection If there is a serial handler the serial handler gets called from this function when serial data are available RETURN VALUE 1 when completed SEE ALSO s2e setup s2e enable s2e disable s2e savesettings s2e recallsettings s2e init s2e printsetup s2e setnetparams s2e connect 022 0099 Rev D 27 Displays the serial port and TCP IP settings in the Dynamic C STDIO window RETURN VALUE None SEE ALSO s2e setup s2e enable s2e disable s2e tick s2e savesettings s2e recallsettings s2e init s2e setnetparams s2e connect Saves all the serial to Ethernet settings to the user block RETURN VALUE 1 if successful 5 if there is an error writing to the user block SEE ALSO s2e setup s2e enable s2e disable s2e tick s2e savesettings s2e recallsettings s2e ini
21. d with the sample programs and recon PLSD Eci po nect your PC to the network OK Cancel 4 Click lt OK gt or lt Close gt to exit the various dialog boxes Once the PC is set up we re ready to communicate You can use Telnet which comes with most Windows installations to view the Ethernet port and you can use Hyperterminal to view the serial port Now we re ready to run the sample programs 022 0099 Rev D 5 Sample Programs Standard Serial to Ethernet Sample Programs The following sample programs are available for the Multi Port Serial to Ethernet Application Kit and can be found in the Dynamic C SAMPLES S2EMULTT folder S2E BASIC C basic sample program involves one RS 232 serial port S2E SAMPLE C basic sample program involves multiple RS 232 serial ports and RS 485 e S2E_ BASIC 5WIRE C basic sample program shows flow control S2E ZCONSOLE C demonstrates Zconsole S2E TEMP SAMPLE C demonstrates use of serial data from sensor S2E HEX C demonstrates the functionality of the serial handler for converting data S2E DVM C demonstrates the functionality of the serial handler with a digital voltmeter S2E RABBITWEB C sample program with ZConsole and optional RabbitWeb configuration In order to run these and other sample programs 1 Your RCM3700 must be plugged in to the Prototyping Board as described in the Multi Port Serial to Ethernet Application Kit Getting Started in
22. dy to look at the main part of the program where s2e_init initializes the userdata member s2e init The serial handler control structure can now be installed for the given serial port with the s2e setserhandler function call s2e setserhandler SERIALPORT serhandler hex The s2e_tick function calls the serial handler when serial data are available s2e tick 022 0099 Rev D 22 Function Reference Guide The Dynamic C SerialtoEthernet 2 0 SER2ETH LIB library provides the function calls used with the Multi Port Serial to Ethernet Application Kit Console support is provided in the SerialtoEthernet 2 0 S2E ZCONSOLE LIB library The following macros are used throughout with the SER2ETH LIB library and the serial to Ethernet sample programs S2E USEPORT_ X where X A to F corresponding to Serial Port A to Serial Port F must be defined prior to the use SER2ETH LIB statement to use the specified serial port For example use the following line for Serial Port D define S2E USEPORT D Enable Serial Port D S2E SERX BUFSIZE where X A to F corresponding to Serial Port A to Serial Port F sets the size of the serial to Ethernet transmit and receive buffers The default is 255 For example use the following line to set a buffer size of 511 for Serial Port D define S2E SERD BUFSIZE 511 Serial Port D buffer size S2E SERX USE HANDSHAKING where X A to F corresponding to Serial Port A to Serial Po
23. ed SEE ALSO s2e init s2e setup s2e enable s2e disable s2e tick s2e savesettings s2e recallsettings s2e setnetparams 022 0099 Rev D 25 Sets the Tx and Rx function callbacks for RS 485 PARAMETERS port is the serial port void tx is a pointer to the transmit callback void rx is a pointer to the receive callback RETURN VALUE 1 when completed SEE ALSO s2e setup s2e enable s2e disable s2e tick s2e savesettings s2e recallsettings s2e setnetparams s2e connect Sets the TCP handler for incoming data PARAMETERS port is the serial port handler is a pointer to the TCP handler callback RETURN VALUE Number of bytes to write SEE ALSO s2e init s2e setserhandler Sets the IP handler for incoming data PARAMETERS port is the serial port handler is a pointer to the serial handler callback RETURN VALUE Number of bytes to write SEE ALSO s2e init s2e setserhandler 022 0099 Rev D 26 Enables the serial port for serial to Ethernet connectivity The serial port must be first set up using the s2e_ setup function call PARAMETER serport is the serial port to enable use the S2E_ SERPORT_X macro where X A to F corresponding to Serial Port A to Serial Port F for this parameter RETURN VALUE 1 if successful 1 if an error occurred SEE ALSO s2e setup s2e disable s2e tick s2e savesettings s2e recallsettings s2e init s2e printsetup s2e setnetparams s2e conne
24. eter LCD are sent out the serial port in packets of 9 bytes The first byte describes the mode and the next two bytes describe the units the next four bytes describe the number on the screen as it is drawn the P is the decimal point the bytes are from right to left as they appear on the LCD The eighth byte represents some special symbols on the LCD and the final byte is a checksum of the packet The sample program converts each packet received into an equivalent ASCII text string that is then displayed in the Telnet window P em I l A G i i The sample program and the manual for the digital voltmeter provide additional information about the nine byte data strings and the voltmeter modes 022 0099 Rev D 13 Web Browser Sample Program One additional sample program is available to illustrate the use of a Web browser with the Multi Port Serial to Ethernet Application Kit A binary image file is available to demonstrate the sample program for users who do not have the Dynamic C RabbitWeb module installed the Dynamic C RabbitWeb module is avail able at a reduced price to customers who have purchased this Multi Port Serial to Ethernet Application Kit If you purchased the RabbitWeb module you will have to install it before you run the RabbitWeb sample program in the SAMPLES Serial2Ethernet 2 folder Like the S2E BASIC C sample program this sample program can be evaluated by tying the Rx and Tx
25. g cable attached You will also need to uncomment the define USE RS485 ON SER E line in the sample program by removing the characters Once you re RS 485 GND a Q Y N E JOm p RS 485 022 0099 Rev D 8 running the revised sample program you can proceed as before You will not see any characters typed in the Telnet window echoed back The RS 485 signals will be on header J1 of the RCM3700 Prototyping Board and can be observed with an oscilloscope Alternatively you may connect an RS 485 device of your own to header J1 to get a visual indication that the RS 485 to Ethernet conversion is taking place S2E_BASIC_5WIRE C This sample program provides an example of five wire RS 232 serial communication with flow control Serial Port D is used as a regular RS 232 serial port and the two flow control signals RTS and CTS are derived from the Serial Port C signals which are used as a digital input and output Before you run this program place one of the jumpers supplied with the spare parts in the Application Kit between the Serial Port D Rx and Tx lines on header J2 on the 2928 RCM3700 Prototyping Board Then place a second jumper between the Serial Port C J2 JE Rx and Tx lines on header J2 Once this sample program is running start a Telnet EFE session Start gt Run gt telnet 10 10 6 100 to the default Telnet socket 23 2 2 With the Telnet client active clic
26. ile in the Dynamic C SAMPLES Serial2Ethernet_2 RabbitWeb folder Select the S2E_ RABBITWEB BIN file then click on Open and press OK to load the file Now remove the programming cable connector from the RCM3700 programming header and press the RESET button on the RCM3700 Prototyping Board Launch a Web browser and enter the URL for this sample program http 10 10 6 100 in the Address line You should be able to bring up a Web console version of the serial console we looked at in the S2E_ZCONSOLE C sample program 022 0099 Rev D 14 RabbitWeb Module Installed Compile and Run Sample Program Before you can compile and run the S2E_ RABBITWEB C sample program you must enable the separate I amp D space compiler option to handle this program s need for more than 24 Kbytes of root data This option is accessible from the Options gt Project Options or the Compiler tab of the Option Project dialog Project Options x Communications Compiler Debugger Defines Targetless Run Time Checking f Optimize For V Array Indices C Size VV Pointers Speed M Iype Checking M BIOS Memory Setting IV Prototype Code and BIOS in Flash IV Demotion Code and BIOS in RAM VV Pointer Code and BIOS in Flash Run in RAM Warming Reports r Max Shown All Errors fio C Serious Only F Noa Warnings fio is List Files I Generate assembly list file for each compile Separate In
27. k write serXwrite databits serXdatabits parity serXparity flowcontrol0on serXflowcontrolon flowcontroloft serXflowcontrolofft TxOn serXTxOn RxOn serXRxOn wrUsed serXwrUsed wrFree serXwrFree 022 0099 Rev D 20 In addition to the function pointers there are several data members that can be used by the handler The serbuf member is a buffer that can be used to store data either temporarily or across handler calls The bufsize member gives the size of the serbuf member in bytes The serlen member is the number of bytes available on the serial port Let s look at the S2E_HEX C sample program The serialhandler hex function takes a sin gle byte from the serial port and translates it into two hexadecimal characters and a space This handler both serves as an example of a serial handler and can be generally useful for looking at the characters from a serial port The serialhandler hex function gets called any time there is a valid TCP connection and there is serial data to process We do not use the userstate in this handler because any bytes that we choose to remove from the serial ports are processed completely If there is not room in the TCP transfer buffer we do not remove characters from the serial port The return value of the serialhandler hex func tion is the number of bytes to send out the serial port The sock_tbleft function can be used to insure the write fit in the buffer The S2E DVM C sample program pro
28. k on the Telnet window appearing on your PC desk top anything you type on your keyboard will be echoed back by the Rabbit and will appear in the Telnet window To convince yourself that the RCM3700 is indeed doing the serial to Ethernet conversion you can remove the jumper between the Serial Port D Rx and Tx lines on header J2 on the RCM3700 Prototyp ing Board and you will no longer see what you type on your keyboard in the Telnet window To check the flow control leave the jumper in place between the Serial Port D Rx and Tx lines on header J2 and remove the jumper between the Serial Port C Rx and Tx lines on header J2 No communication will occur when this Serial Port C jumper is removed Instead of using a jumper across the Serial Port D Rx and Tx lines on header J2 on the RCM3700 Prototyping Board you may use the long Col d 10 pin header to DB9 cable to connect header J2 to your PC COM 9 a port Line up the colored edge of the cable with pin 1 on header J2 as age shown in the diagram pin 1 is indicated by a small square on the Prototyping Board silkscreen Note that two of the lines in the cable opposite the colored side are not connected to the 10 pin connector p Open a Hyperterminal session Start gt Accessories gt Commu nications Select the COM port the cable is connected to and set the J2 lacana default serial parameters 2 RE x 2 Bits per second 115200 Data bits
29. n to the PC for Serial Port D 022 0099 Rev D 12 S2E_DVM C This sample program demonstrates the serial handler functionality with the Radio Shack 22 812 digital voltmeter This digital voltmeter has a at 4800 baud serial port that sends information about what is on the screen out its serial port The functionality of the serial handler is documented in the appendix Before you run this sample program use the long 10 pin header to DB9 cable Part No 540 0085 and a DB9 male to DB9 male null modem cable not included to connect header J2 on the RCM3700 Prototyp ing Board to the serial port on the digital voltmeter Turn the digital voltmeter on and press the SELECT and RANGE keys at the same time to turn on the serial port interface on the meter Use the digital voltme ter to measure a voltage for example between the 5 V and GND traces on the RCM3700 Prototyping Board Crossover Ethernet Cable RONGSGTIR SERIES O M DE9 Null Modem Cable Serial Digital Voltmeter Once the sample program is running start a Telnet session Start gt Run gt telnet 10 10 6 100 with the default Telnet socket 23 An ASCII text representation of the serial data sent by the digital volt meter will be displayed in the Telnet window The data from the digital voltm
30. on first and then click on the Properties button to bring up the Ethernet interface dialog Then Configure your interface card for a T 10Base T Half Duplex or an Auto Negotiation connection on the Advanced tab Add Remove Properties Primary Network Logon gt Xircom CreditCard Netwave Adapter NOTE Your network interface card will likely Microsoft Family Logon have a different name Eile and Print Sharing r Description TCP IP is the protocol you use to conng to the Internet and wide area networks 3 Now select the IP Address tab and check Specify a 2 an IP Address or select TCP IP and click on Prop anal 4x erties to fill in the following fields General You can get IP settings assigned automatically if your network supports IP Address 10 10 6 101 ue ecm dla ates need to ask your network administrator for Netmask 255 255 255 0 Obtain an IP address automatically Default gateway M 10 10 6 1 Use the following IP address Ss IP address 10 10 6 101 TIP If you are using a PC that is already on a Subnet mask 255 255 255 0 network you will disconnect the PC from that Default gateway 10 10 61 network to run these sample programs Write CM Dee N own the exis in se ings erore cnan in Use the following DNS server addresses d th t tt bef h E them to facilitate restoring them when you are Prefered DNS server ae finishe
31. r keyboard will be echoed back by the Rabbit and will appear in the Telnet window To convince yourself that the RCM3700 is indeed doing the serial to Ethernet conversion you can remove the jumper between the Serial Port D Rx and Tx lines on header J2 on the RCM3700 Prototyping Board and you will no longer see what you type on your keyboard in the Telnet window 022 0099 Rev D 6 Instead of using a jumper across the Serial Port D Rx and Tx lines on header J2 on the RCM3700 Prototyping Board you may use the long 10 pin header to DB9 cable Part No 540 0085 to connect header J2 to your PC COM port remember to disconnect the programming cable if you only have one COM port Line up the colored edge of the cable with pin 1 on header J2 as shown in the diagram pin 1 is indi cated by a small square on the Prototyping Board silkscreen Note that two of the lines in the cable opposite the colored side are not con nected within the 10 pin connector Colored edge 4 J2 Open a Hyperterminal session Start gt Accessories gt Commu nications Select the PC COM port the cable is connected to and set the default serial parameters GND o TxD o o RxD o o TEjo o GND o o Bits per second 115200 Data bits 8 Parity None Stop bits 1 Flow control None With the Hyperterminal client active click on the Hyperterminal window appearing on your PC desktop and the Telnet se
32. rial data bits parity even odd none 2 serial parity 2 2 stop bits f ow on off enable hardware flow control i pmode isten 0open tisten or actively open connection rport lt tcp port gt remote port 0 65536 to use lport lt tcp port gt ocal port 0 65536 to use raddress lt ip address gt remote IP address to connect to flush on off enables socket flushing 022 0099 Rev D 10 e SET NET is used in the context set net lt parameter gt The following parameters can be set ip lt ip address gt exa 10 10 6 99 netmask lt net mask gt exa 255 255 255 0 gateway lt gateway gt exa 10 10 6 1 dhcp on off enable or disable DHCP nagle on of f turn nagle on or off keepalive on of f turn on TCP keepalives alivetime lt seconds gt how often to test keepalive When you change any settings you must store them and restart the device before the changes will take effect If you changed the IP address you will have to start a new Telnet session to the new IP address S2E_TEMP_SAMPLE C This sample program illustrates using a serial device the QK145 temperature sensor to provide the serial data E O GND o o RxC o O TxC o o RxE og Before you run this sample program use the short 10 pin header to DB9 cable to connect the QK145 temperature sensor to Serial Port D via header J2 on the RCM3700 Prototyping Board Most of the time the RS 232 chip on the P
33. rototyping Board can supply sufficient cur rent to operate the QK145 temperature sensor connect pins 1 3 and pins 2 4 on header JP2 on the Prototyping Board to configure Serial Port E for RS 232 operation Colored edge i Once the sample program is running start a Telnet session Start gt Run gt telnet 10 10 6 100 1230 to the IP address 10 10 6 100 and Telnet port 1230 The serial data sent by the QK145 temperature sensor will be displayed in the Telnet window Crossover Ethernet Cable wat affo Temperature Sensor Kit EET ET O50 Oooo Ttatise tists 19Q000000000000 DS18S20 sensor Optional 5 V and GND connections KKK K Q 022 0099 Rev D 11 Should you encounter any problem viewing the data output in the Telnet window once the sample program is running you will have to connect the QK145 temperature sensor to the 5 V and GND traces on the Prototyping Board S2E_HEX C This sample program demonstrates the functionality of the serial handler using the serial to Ethernet library with Serial Port D and the standard Telnet port 23 The serial handler takes a single ASCII byte from the serial port and translates it into two hexadecimal characters and a space which makes it easier to observe and process certain
34. rt F must be defined prior to the use SER2ETH LIB statement when using RTS CTS Handshaking for the specified serial port For example use the following line when using Serial Port D for Rx and Tx with RTS CTS on Serial Port C define S2E SERD USE HANDSHAKING Enable Serial Port D flow control S 2E ACKNOWLEDGE will send an acknowledgement message to both the serial port and the TCP IP connection when a socket connection is made S2E ACK MESSAGE is the message string to send when S2E_ACKNOWLEDGE is used define S2E ACK MESSAGE This is a sample message S2E SERPORT X where X A to F corresponding to Serial Port A to Serial Port F is used in the s2e setup s2e enable ands2e disable function calls e S2E_ ACTIVE OPEN configures a serial port in s2e setup asa TCP client that connects to a TCP server e S2E ACTIVE LISTEN configures a serial portins2e setup asa TCP server that will listen for a connection from a TCP client S2E STARTING STORAGE ADDR is the starting location in the user block for storage and retrieval of all serial port TCP IP settings The default starting location is 0 Two debugging macros are handy when debugging applications written with the SER2ETH LIB library S2E DEBUG allows you to single stepping through the library S2E VERBOSE displays status information for the s2e_tick function call 022 0099 Rev D 23 The following function calls are in the SER2ETH LIB library
35. ssion you started before still running anything you type on your keyboard will be echoed back by the Rabbit and will appear in the Telnet window With the Telnet client active click on the Telnet window appearing on your PC desktop anything you type on your keyboard will be echoed back by the Rabbit and will appear in the Hyperterminal window Note that you will not see what you are typing in the active window unless you have enabled the local echo To select a different serial port change the S2E_USEPORT_D and S2E_ SERD BUFSIZE macros in the sample program To select a different TCP IP port change the TCPPORT macro in the sample program Note that the long 10 pin header to DB9 cable Part No 540 0085 only provides a serial connection to the PC for Serial Port D S2E_SAMPLE C This sample program is similar to the S2E_BASIC C sample program except three serial ports Serial Ports C D and E are enabled for three wire RS 232 serial communication with a unique TCP IP port socket corresponding to each of the three serial ports TCP IP ports or sockets are used whenever multiple devices are associated with a single IP address Serial Port C port 1231 Serial Port D port 1232 Serial Port E port 1233 Before you run this program place jumpers between the Serial Port C D and E Rx and Tx lines on header J2 on the RCM3700 Prototyping Board as ae shown Also pins 1 3 and pins 2 4 on header JP2 on the Prototyping JP2 8 J2
36. struction amp Data Space VV Enable separate instruction and data spaces M Default Compile Mi Compile to attached target C Compile defined target configuration to bin file Compile to bin file using attached target In line 1 0 IV Inline builtin 1 0 functions Now open the S2E_RABBITWEB C sample program and compile and run it by pressing F9 You could get a target not responding message because the console will interrupt the debugging interface but you may ignore that message Remove the programming cable from the RCM3700 programming header and press the RESET button on the RCM3700 Prototyping Board Launch a Web browser and enter the URL for this sample program http 10 10 6 100 in the Address line You should be able to bring up a Web based console that is similar to the serial console we looked at in the S2E_ZCONSOLE C sample program 022 0099 Rev D 15 Web Console The Web console has Network SERO and SER1 tabs which correspond to the SETNET and SETx commands in the S2E_ZCONSOLE C sample program with SERO Serial Port D and SER1 Serial Port E Once you have changed to parameters on a Web console screen press the Submit button to save them or press the Recall button to recall the previous settings New settings will not take effect until you press the Store button which comes up after you press the Submit button and then the Restart button File Edit View Favorites Tools Help
37. structions 2 Dynamic C and the supplementary Multi Port Serial to Ethernet Application Kit software must be installed and running on your PC 3 The programming cable must connect the programming header on the Prototyping Board to your PC 4 Power must be applied to the RCM3700 through the Prototyping Board To run a sample program open it with the File menu compile it using the Compile menu or press F5 and then run it by selecting Run in the Run menu or press F9 If you only have one PC or notebook available disconnect the programming cable once the sample program is running Then press the RESET button on the RCM3700 Prototyping Board to restart the RCM3700 in the Run mode S2E_BASIC C This sample program gives a very basic example of three wire RS 232 serial communication using the serial to Ethernet library with Serial Port D and the standard Telnet port 23 Before you run this program place one of the jumpers supplied with the spare parts in the Application Kit between the Serial Port D Rx and Tx lines pins 3 and 5 on header 223 J2 on the RCM3700 Prototyping Board Be careful not to confuse header J2 with J2 nearby header JP2 Once this sample program is running start a Telnet session Start BR2SKs Grae G gt Run gt telnet 10 10 6 100 with the default Telnet socket 23 Once the Telnet client is active click on the Telnet window appearing on your PC desktop any thing you type on you
38. t s2e printsetup s2e setnetparams Retrieves all the serial to Ethernet settings from the user block RETURN VALUE 1 if successful 5 if there is an error writing to the user block 6 if there were no previous data saved SEE ALSO s2e setup s2e enable s2e disable s2e tick s2e savesettings s2e recallsettings s2e init s2e printsetup s2e setnetparams Rabbit Semiconductor Inc www rabbit com 022 0099 Rev D 28
39. twork disconnect it from the network Check with your administrator if you are unable to change the settings as described here since you may need administrator privileges The screen shots shown here are from Windows 2000 and the interface is similar for other versions of Windows 1 Go to the control panel Start gt Settings gt Control Panel and start Network Connections J Control Panel iol x File Edit View Go Favorites Help e fa i g Back Forward Up Cut Copy Paste Address Control Panel be Internet Keyboard Mail and Fax Modems Options Control a2 A Pa nel Multimedia NetModem nN Network Ua Configures network hardware and software Power rare PRISM Regional Management Settings Settings m B B SJ My Computer Microsoft Home mi4 022 0099 Rev D 4 2 Select the network interface card used for the Ethernet interface you intend to use e g TCP IP Xircom wane ix Credit Card Network Adapter and click on the Configuration identification Properties button Depending on which version of The following network components are installed P NETGEAR MA401 Wireless PC Card i Xircom CreditCard Netwave Adapter Y Fast Infrared Protocol gt IBM ThinkPad Fast Infrared Port TCP IP gt Dial Up Adapter YT TCP IP gt NETGEAR MA401 Wireless PC Card Y TCP IP Windows your PC is running you may have to select the Local Area Connecti
40. twork connection from an external host PC via Telnet Once the network connection is made the software simply moves bytes between a serial port s Tx and Rx and the network connection s socket The Multi Port Serial to Ethernet Application Kit Getting Started instructions included with the Applica tion Kit show how to set up and program the RCM3700 What Else You Will Need Besides what is supplied with the Application Kit you will need a PC with an available COM or USB port to program the RCM3700 in the Application Kit If your PC only has a USB port you will also need an RS 232 USB converter Part No 540 0070 To run the S2E_DVM C sample program which uses a digital voltmeter to illustrate the use of the serial to Ethernet serial handler you will need a digital voltmeter with a serial port such as the Radio Shack 22 812 digital voltmeter and a DB9 male to DB9 male null modem cable 022 0099 Rev D 1 Configuration Information Network IP Address Configuration Any device placed on an Ethernet based Internet Protocol IP network must have its own IP address IP addresses are 32 bit numbers that uniquely identify a device Besides the IP address we also need a net mask which is a 32 bit number that tells the TCP IP stack what part of the IP address identifies the local network the device lives on as well as which host it is connected to The sample programs supplied with this Multi Port Serial to Ethernet Application Kit
41. vides an example for using the userstate member The serial to Ethernet control structure has certain states and data The sample program shows how the control structure is used to set up the serial handler int serhandler hex S2EControl ctrl The line below ensures that only as many bytes as can be transmitted are read Since one byte is converted into a three character hex representation the number of original bytes is multiplied by three if ctrl gt serlen 3 gt sock tbleft amp ctrl gt sock ctrl gt serlen sock tbleft amp ctr1l gt sock 3 The same action needs to happen on the buffer so that the buffer and the memory do not overflow If there is not buffer space to write the full amount characters may be dropped Lf ctrl gt serlen 3 gt ctrl gt bufsize ctrl gt serlen ctrl gt bufsize 3 memset ctrl gt serbuf 0 ctrl gt bufsize Next the bytes are read from the serial port and are replaced ctrl gt read ctrl gt serbuf ctrl gt serlen 5L for x ctrl gt serlen 1 x gt 0 x The least significant nibble is done first because we do not want to overwrite the number before we calcu late the most significant nibble The hex conversion is done nibble by nibble When the least significant nibble is done the actual byte is replaced and the space is written 022 0099 Rev D 21 The serial handler should return the number of bytes to write to the TCP port return ctrl gt serlen 3 We re now rea
Download Pdf Manuals
Related Search
Related Contents
Betriebsanleitung Operating Manual Gebruiksaanwijzing Mode d 1101 05 Rev1 UM TV PH50A30PSG 3D.cdr InLine 00243B mounting kit X95PC - FR - version 1.3 EVGA 01G-P3-N809-AR GeForce 8800 GT 1GB graphics card Copyright © All rights reserved.
Failed to retrieve file