Force device into download mode...

Posted on 2008-11-19
Medium Priority
Last Modified: 2013-11-26
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!
Question by:jasgiv1122
  • 5
  • 4
LVL 16

Expert Comment

ID: 23002950
Hi, unfortunatelly, i have no clue regarding VB.net.
You see, i am in the Old and Good School of VB6.

Author Comment

ID: 23004240
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?
LVL 38

Expert Comment

ID: 23029170

If you post the code that you have tried, it might help us help you.
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.


Author Comment

ID: 23034765
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

LVL 38

Expert Comment

ID: 23045924
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.

Author Comment

ID: 23056101
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.  
LVL 38

Expert Comment

ID: 23056364
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.
LVL 38

Expert Comment

ID: 23056375
To clarify, you need to try opening the port, sending the command and closing the port, then running the batch file.

Author Comment

ID: 23161844
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 :/

Accepted Solution

jasgiv1122 earned 0 total points
ID: 23193430
any help is appreciated!

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month15 days, 6 hours left to enroll

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question