Jim Nickerson
 
Reged: Oct 16 2003
Posts: 60
Loc: San Diego, CA USA
|
|
How I connected to a serial device across Ethernet. The board I used is the MICROCHIP PICDEM.net 2 board DM300004-2 available from http://www.microchipdirect.com/productsearch.aspx?Keywords=DM300004-2
The software used is Microchip’s TCP/IP stack 4.16 available from http://ww1.microchip.com/downloads/en/DeviceDoc/TCPIPStack%204.16.zip
In HardwareProfile.h uncomment #define PICDEMNET2 In TCPIPConfig ensure #define STACK_USE_UART2TCP_BRIDGE is uncommented. Compile and program the Demo App. Press and hold the RB3 button while resetting the board to force the use of your just programmed values for ip, gateway etc. After the 4 leds light up release the RB3 button. Your board should be running with the ip address displayed on the LCD and the right hand led blinking. Execute MPFS2.exe from the \Microchip\TCPIP Stack\Utilities directory Step 1 Source settings select Pre-Built MPFS Image Browse to and select TCPIP Demo App\MPFSImg2.bin file Step 4 Upload Settings Upload MPFS Image Settings Try with the defaults or Board Address -> set to the address displayed on the LCD Upload Path -> mpfsupload User Name: -> admin Password: -> microchip The web pages should be uploaded.
You should now be able to access the web server at the ip address you specified. Test the uart 2 tcp bridge using telnet. I tested this on my XP computer. From a cmd window: telnet 192.168.0.17 9761 Use the ip address displayed on the LCD. If all goes as planned the cmd window screen will go blank indicating you are connected. Use hyperterm or your favorite terminal program to connect to the serial port on the PICDEM.net 2 board. You should now be able to type in the telnet cmd window and the characters should appear in the hyperterm window and vice versa. If you have gotten this far all is working as desired. In the cmd window type ‘CRTL+]’ to escape to the telnet command mode and issue the q command to quit telnet.
Now to add a virtual com port that will connect via Ethernet to the PICDEM.net 2 serial port. From http://com0com.sourceforge.net/ get the Com0Com virtual port software. It comes as source code and requires the Microsoft DDK to build it. The readme details building it from a cmd window obtained with C:\WINDOWS\system32\cmd.exe /k C:\WinDDK\6000\bin\setenv.bat C:\WinDDK\6000\ fre WXP This shortcut is available on the start menu after installing the DDK. The alternative way is to create a VisualStudio project and get the OSR cmd file from http://www.osronline.com/article.cfm?article=43 Install the cmd file and add the environment string, as detailed within the ddkbuild.bat file. After building the Com0Com device driver build an installer using NSIS available from http://nsis.sourceforge.net/ Or if you are interested in all the defaults and are running on XP use the attached binary I made Com0Com1.8.0.0.setup.exe Running the Com0Com… setup program installs the virtual com port driver and a start menu shortcut to the setup program and the readme detailing how to use it. During the install do not search the net for updates and then install automatically. Two devices are installed. The virtual com port exists as ‘CNCA0’ and the other half ‘CNCB0’. What goes in one comes out the other. For the next step get Com2Tcp from http://sourceforge.net/project/showfiles.php?group_id=129551 Com2Tcp is distributed as source files complete with a VisualStudio workspace. For those who are willing to use the defaults you may use the attached binary I built com2tcp.exe
Configuring the virtual com port. Start, Programs, com0com, Setup CommandPrompt ‘Change CNCA0 PortName=COM3’ this command will rename ‘CNCA0’ to COM3 in case your communications software can not see ‘CNCA0’, do not overwrite an existing port.
Configuring the com2tcp program. com2tcp.exe --telnet \\.\CNCB0 192.168.0.17 9761 Change the ip address to that displayed on the LCD, port 9761 is set in the 4.16 stack.
Test using 2 instances of hyperterm ( or your favorite terminal program ). Connect to port COM3 ( the virtual port )on one and COM1 ( the physical com port ) connected to the com port on the PICDEM.net 2 board on the other.
I wrote these notes to jog my memory when I come back to this project. These steps should be executed in sequence resolving problems as they occur before proceeding to the next step. Each step is predicated on the previous step working.
There is no warranty for these instructions or software, they are provided “as is” without warranty of any kind, either expressed or implied, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose. The entire risk as to the quality and performance of the program is with you. Should the program prove defective, you assume the cost of all necessary servicing, repair or correction. Com0Com and Com2Tcp by Vyacheslav Frolov. Please feel free to contact me if you find this does not work as described. I will be happy to correct my description.
-------------------- HI-TECH Certified Consultant
Microchip Authorized Design Partner
www.JimNickerson.org
|
|