Thread: Upload and Download Files quickly

  1. #1
    Registered User
    Join Date
    Aug 2012
    Posts
    21

    Unhappy Upload and Download Files quickly

    It has been many years since I did much C programming but I Have Been Given the job of adding some capabilities to two existing programs. One is a VB6 program that runs on a PC. The other is a C program running on a picoflash single board computer from JK microsystems. The two computers are connected by an Ethernet link.
    Both programs are being developed using the “XP Mode” in Windows 7. The C program is being developed using Borland C++ version 4.52 IDE. It is configured for the 16 bit 80186 instruction set.

    The capability that I am working on now is to upload and download files from the Pc to the picoflash single board computer. The action is always initiated at the PC. Data packets are exchanged over the Ethernet link to get the job done. I have done this by sending short packets that I construct passing commands and data back and forth. My problem is that it is too slow. It takes up to six minutes to pass one text file of 600 short lines.

    The existing program uses the Wattcp programs developed by Erick Engelke. His manual file contains the statement “For exanple, you can add an FTP server to your applications with just one line of code.” In 1992 he indicated that he doesn’t have time to help people with this and the web site he gave goes to a dating service now.

    My code now makes use of the following commands.

    Code:
     
    #include <tcp.h>
    tcp_tick();
    sock_established()
    sock_close();
    sock_wait_closed();
    StartEthernet();
    (sock_dataready()
    sock_gets
    sock_puts();
    Can someone point me in the right direction to pass these files quickly?

    Jerry

  2. #2
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    O_o

    Wow.

    This might be one of the more esoteric things I've seen here.

    I have to ask, what is the maximum theoretical bandwidth for the connection on the side of the embedded device?

    Soma

  3. #3
    Registered User
    Join Date
    Aug 2012
    Posts
    21
    I don’t know how to find the “maximum theoretical bandwidth” but some related factors are:
    1- The picoflash has a 40MHz 186 compatible processor according to the web site (picoFlash - JK microsystems, Inc.)
    2- Using the TFTPD SERVER (JKmicro TFTPD version 1.04, 80186) on the picoflash
    And the command prompt TFTP on the PC will download 40,331 bytes in 1 sec and 288,914 bytes in 2 sec.
    3- The 40,331 byte file is the same one my program takes 6 minutes to download.

    Jerry

  4. #4
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Your file isn't large. I can't help you with the TCP/IP, but I am wondering if the hyper terminal feature wouldn't do the job, with a simple serial cable?
    LogicFlex embedded Ethernet SBC runs TCP/IP Lean - JK microsystems, Inc.

  5. #5
    Registered User
    Join Date
    Aug 2012
    Posts
    21
    The hyper terminal feature is already used in this system. The VB6 program doesn't have access to it.

  6. #6
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,909
    I guess it's not likely a hardware issue, since TFTP works well. Looks like there's not an issue of a slow proc or ethernet connection. Why not use the TFTP program provided? There are free TFTP libraries out there that you can use from the PC end.

    It's really hard for us to say without more info. Code would be good. What is this program of yours doing exactly? What are these socket routines you mentioned in your first post? Is there strange handshake or configuration requirements in your protocol that slows stuff down? Are you sending a bunch of one-byte packets with a lot of overhead from your custom protocol?

    Do you print lots of debug and status messages to find out what your program is doing? Do you check the return value of all your socket/IO calls and print useful debug messages to help you track down this problem? What do the messages say?

    EDIT: Can you compare the TFTP program for the picoFlash to what you wrote and see how they differ?
    Last edited by anduril462; 10-12-2012 at 12:56 PM.

  7. #7
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Looking at the doc's, I wonder whether the board can't just take a filename and use redirection.

    command filename

    or

    command > filename

    Because I don't believe they want their customers to have to write their own program to chop the data into packets, etc.

  8. #8
    Registered User
    Join Date
    Aug 2012
    Posts
    21
    anduril462 asked "What is this program of yours doing exactly?"

    The picoflash single board computer from JK microsystems is imbedded in a product called a Critical Process Controller (CPC). It can be expanded in modules including hundreds of analog and digital inputs and outputs. It can be used in a stand alone mode operating for example an autoclave in a manufacturing plant. A hyper terminal can be connected to monitor status and diagnostic printout. An operator interface program can be added that communicates through an Ethernet connection. The system was designed and the code written by the company I am supporting.
    I have been asked to add the ability to upload and download files between the CPC and the PC. I am trying to learn what it does as I go.

    anduril462 asked “Are you sending a bunch of one-byte packets with a lot of overhead from your custom protocol?” Unfortunately that is close. I am working on a way to combine the packets so it has less overhead.
    I don’t know much about how FTP is normally implemented so, I was hoping to get some direction from the forum.
    I will be digging into your other questions.
    Jerry

  9. #9
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,662
    > In 1992 he indicated that he doesn’t have time to help people with this and the web site he gave goes to a dating service now.
    Odd, the site I found is exactly what it should be, and is dated 2007, which given the scale of things seems respectably recent by comparison.
    WATTCP for Embedded Systems and User Applications

    Run wireshark/ on the host PC and use it to observe the network connection to the target board.

    I can imagine two scenarios:
    - the file being dribbled over the wire a few bytes at a time.
    - the whole file being transferred quickly, then a broken handshake at the end resulting in a wait for a timeout.

    Wireshark will be able to tell you exactly how the link is being used.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  10. #10
    Registered User
    Join Date
    Aug 2012
    Posts
    21
    Thank you all for your comments. I solved my problem by changing the overhead in what I was doing. The download that took six minutes now takes six seconds.

    Jerry

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. upload / download speeds
    By Dino in forum Tech Board
    Replies: 20
    Last Post: 11-25-2008, 09:06 PM
  2. download/upload speed calculations
    By X PaYnE X in forum Networking/Device Communication
    Replies: 1
    Last Post: 06-09-2006, 11:04 AM
  3. getting upload and download bandwidth
    By hanhao in forum C++ Programming
    Replies: 19
    Last Post: 03-19-2004, 11:19 AM
  4. Can we upload files for future ref for others?
    By aspand in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 06-12-2002, 11:13 PM
  5. Copying Files Quickly
    By Dan in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 03-31-2002, 04:18 AM