Force device into download mode...

I've been battling this for a few days now and I stumbled upon this post that is very similar to what I'm trying to accomplish.  It uses the exact output also, the xdld command to put the device in download mode.  I don't need this process automated however, and I don't want it to do it on startup.  I just cant seem to get the code right for opening com1 and sending it the right xdld command.  I'm using visual basic 2003 and I know it should be just a few lines, but I'm a novice in this area.  Any help in this area is much appreciated, again... all I need to do is open com1, utilize the XDLD command and then I have a separate batch file that will download the file once it is in that mode.  Thanks for any help!
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Richie_SimonettiIT OperationsCommented:
Hi, unfortunatelly, i have no clue regarding
You see, i am in the Old and Good School of VB6.
jasgiv1122Author Commented:
Was the post I referenced in vb6?  I may have misjudged what language it was - Any help is appreciated... Does anyone know if it's possible to do it in .Net?

If you post the code that you have tried, it might help us help you.
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

jasgiv1122Author Commented:
This is what I used, but I get an application error when I run it.
Module Module1
    Sub Main()
        'New a MSComm control
        Dim MSComm1 As MSComm
        MSComm1 = New MSComm
        ' Buffer to hold input string.
        Dim Buffer As String
        ' Use the COM1 serial port.
        MSComm1.CommPort = 1
        ' 9600 baud, no parity, 8 data, and 1 stop bit.
        MSComm1.Settings = "9600,N,8,1"
        ' Tell the control to read the whole buffer when Input is used.
        MSComm1.InputLen = 0
        ' Open the serial port.
        MSComm1.PortOpen = True
        Console.WriteLine("Open the serial port.")
        ' Tell the control to make the Input property return text data.
        MSComm1.InputMode() = InputModeConstants.comInputModeText
        'Clear the receive buffer.
        MSComm1.InBufferCount() = 0
        ' Send the attention command to the modem.
        MSComm1.Output = "xdld"
            Buffer = Buffer & MSComm1.Input
        Loop Until InStr(Buffer, "OK" & vbCrLf)
    End Sub
End Module

Open in new window

Well, that looks a lot like VB6 code.  If you're getting an application error it's probably because the MSCOMM32.OCX is not available for use like this.

Try a .NET solution for comm communications:

That sample project should allow you to experiement sending the right download code to your device.
jasgiv1122Author Commented:
Thanks for that valuable piece of information! The next wall I've run in to, is that I'm trying to call a batch file after the port is open and the command has been sent - this has to be within the same application, right?  When I just run the batch file by itself after trying to send the command, it seems to just think the port is closed or in use.  
I was wondering about that... Unless you close the port from the application, your batch file won't work.  I'm guessing the batch file does a redirect of a file to COM1: or something similar.
To clarify, you need to try opening the port, sending the command and closing the port, then running the batch file.
jasgiv1122Author Commented:
Ok, after weeks of waiting for a response from the manufacturer, I have it.  I have the command I'm supposed to use, but I'm stuck on getting anything to communicate to it.

REQ: <STX>XDLD<FS>FileName<FS>DownloadType<FS>[ForceRestart]<ETX>{LRC}
RSP: <STX>XDLD<FS>RetVal<FS>RetValString<ETX>{LRC}
FileName = name of file to be downloaded
DownloadType =
'P' = PARTIAL download (contents of file system are NOT erased)
'F' = FULL download (contents of file system are erased)
ForceRestart = 1 = Force restart the application
2 = Force restart the Device
RetVal = 0 - Unsuccessful operation
1 - Successful operation
RetValString - contains a text description of the result.

Is there anyway you can guide me through setting this up in Visual Studio 2003?  I tried inputting this into apps, but it doesn't communicate.

Hopefully you can offer any kind of solution!  Thanks

It would be better if I could just have this all happen in a console application and open my port, then send the command, then possibly prompt the batch file I have that sends the file...  I've invested hours upon hours with trial and error, and nothing to show for it :/
jasgiv1122Author Commented:
any help is appreciated!

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.