USB to Serial ports.

Is there any new support for USB to serial connections or extended ports.  I  would like to use an extended port and have no luck trying to read of the port. e.g. com20 even though the protocols are the same as com 1-4. Do I need to add something, or is it possible?

John P.

Hi John,

 
I have been using 2 and 4 port USB-Serial converter boards containing FTDI chips without any problems on a Windows7 64 bit system.  The only requirement for those particular boards is that they need to be plugged into the computer's USB port direct and not via a USB hub.
I would assume that if the ports show up in Device manager they should work like any other serial port.
 
Regrads,
 
John   

I do have a comm port setup in device manager as any other port. I tried the capture demo.  I tried to simply change the port number on VAComm, and tried to change protocols using the VAconfig dialog.  The demo works fine on standard com port 1 as an example.  I would think it should behave the same on a defined USB to Serial comm port 20 or any other port number with the same setup, however it cannot access that port without error.

I am using Delphi 7 with my TMSAsync component set under XP Pro. I am beginning to wonder if there is a problem with developing under a 32 bit environment and running under 64 bit systems somewhere with USB drivers or something else may be a problem.  I ran into a similar issue a couple of years ago. My only resolution was to stay with standard comm ports that I had done with AsyncPro, which I can no longer do unless it has made a come back. My application is fairly simple. I am reading data from weigh scales. Unfortunately this is kind of a one time application, which makes it hard for me to do justify upgrades to systems all around. So I need a solution with what I have now.

Any comment is appreciated that will hopefully lead me in the right direction.


John P.

Does your application use Hardware or software flow control? Some of the troubles I have experienced in the past is that the USB converters/drivers mostly do stricly enforce flow control. So if your weigh scales don't need it then you need to make sure it is switched off in your application.  

I have gone through all those settings and options. Still no luck. It seems others are having issues with this too on Windows 7 and other serial components. I have gone through all those settings and options.



Yes, I have also had some problems with a few of the older converters. Sometimes they also don't have the appropriate drivers for windows7 and you might not be able to install them correctly. At other times the drivers work ok on Win7 32 bit but not on 64 bit machines. I could only suggest using a different type of converter. I use  a couple of 1,2 and 4 port USB-COM232- boards made by FTDI. See http://www.ftdichip.com/Products/Modules/USBRSxxx.htm 

They have been working reliably for me and are cheap.

This message may be a repeat as something seemed to go wrong with my post. I am rewriting.  Anyway I don't think it is a cable issues since I can use Putty or other Terminal programs and run off my USB to serial com port. I can see all scale data coming in. I must be doing something wrong or not using the right components correctly.  I cannot run the TMS demo Capture program, which the connection seems OK on the others but does not bring in data after trying various mods.  I am wondering if I can get sample demo that would capture some data from a scale. Here is working code from from AsyncPro if that helps, which I would like to put into TMS Async 32, and of course need to run of USB to Serial com ports.


const
  
   MAXCHARS = 20;
   VALIDCHARS = [ '0'..'9', '.', ',', 'a'..'z', 'A'..'Z' ];

var
   I, X : Integer;
   C : Char;
   S : String;
   LastError : Integer;
begin
 
   LastError := errSuccess;

  
   setlength( S, MAXCHARS );

   // Collect the ASCII characters that come back,
   // discarding the STX and ETX characters along
   // the way.
   I := 0;
   X := 0;
   while ( ( X < MAXCHARS ) and ( I < Count ) ) do
   begin
     inc( I );
     C := ApdComPort2.GetChar;
     if ( C in VALIDCHARS ) then
     begin
       inc( X );
       S[ X ] := C;
     end;
   end;

   // Get rid of any remaining input.
   ApdComPort2.FlushInBuffer;

   // Trim any spaces/junk that came back
   S := trim( S );

   // Strip units notation
   X := pos( ' ', S );
   if ( X > 0 ) then
     S := copy( S, 1, X-1 );
  // ShowMessage('Scale is reading:' + S);
   LabelWeight.Caption := S;

 
   end;

TVaComm does not have a GetChar() function. Use function ReadChar(var Ch: Char): Boolean.

You will need to use function ReadBufUsed: Integer to check if there are any characters waiting for you to read.





Some simple C code I use which I run after sending a command to a data logger, It waits for the start of a reponse first. and then collect data after the serial port stops receiving data for about 50 milliseconds:



int __fastcall TPS310::GetResponse(char *Response, int TimeOut)

{

   int count = 0;

   int timeOut = TimeOut * 20;

   int y=0;



     while((Port->ReadBufUsed() == 0) && (y++ <= timeOut))

      {

      Application->ProcessMessages();

      Sleep(50);

      }



   timeOut = TimeOut * 20;



   for(int x=0;x< timeOut; x++)

      {

      Application->ProcessMessages();

      ProcessCommunications();

      Sleep(50);



      if(count == Port->ReadBufUsed())

           {

                break;

           }

      else

           {

           count = Port->ReadBufUsed();

           }

      }



return Port->ReadBuf(Response,Port->ReadBufUsed());

}


I am still having trouble with this. I am wondering if you or anyone else may be able to help me. My AsyncPro has failed me since I upgraded from version 4.6.to 5 without any code changes!  I think I need to re-write or see all of this code above somehow with TMS Async32  since there are indications of  it working with USB to serial. But first test on standard ports as I can still resort to serial cards.  I am using Delphi 7under an XP Pro and Win 7 systems, and of course have purchased TMS products. 

Right now my main goal seems to be just capturing a whole string with a start and end character into a var, label or some other container, and to get that string I need to send a 'W'+#13 to the scale.  You would think that would be easy but I am missing something simple, which of course I am driving a new wheel here.

John


Send me the function where you try to collect the data from the serial port. I do all my coding in C normally but looks like Delphi is not that hard anyway.   

Do you put a TVaCommcomponent on a form and use it that way?

Hi John,

From what I read, I likely just need a demo using VaCapture with VaComm. Once I get my characters into a container of some sort. (prefer data before the start and end characters).  I can later do what I need to do with that string. I would think this would be just one or two lines of code.

I can get data into a label caption. I was just using the demo terminal program with VAComm.  However that data is a continuous stream and not between the start and end characters, or a fixed length, which I also use a timer to slow down to see.

In the future it would be nice to see a property or way to ignore characters on a capture, such as the start and end, alpha characters, or any other extended characters. That would make for a nice scale or bar code reader as an example.

There are no demos and not much information on the use VaCapture, which I believe is all I need to get going.

Thanks for you help.

John P.


Hello,



ran into a similar Problem when trying to read from the native USB port from the Arduino Due.



I got data with the Arduino IDE, with a Serial logger, but was unable to get some with the capture demo. On the other Hand I was immediatly able to read data from the programming port of the Arduino DUE (what is a "regular" COM port on the PC side). After playing a while with the Settings the reason was quite simple:



The USB virtual COM port for this device (Arduino Due) Needs DTR or RTS enabled - may be that solves your Problem too (if it still exists).

Uups - didn't read correct. You seem to get data but are unable to get Capture working.



However - may be the post before is helpfull to somebody who plays around with Arduino the first time (as I did) ... :-)

John,



   I use Async32 for several years now.   I haven't had any problem reading comm ports of USB adapters, even through a hub.   Just finished an application and test fixture for communicating with 8 and 16 serial devices.



   The trick is getting the component to tell you what ports are available.



TComboBox      PortComboBox;

TVaComm             CommPort;



void __fastcall TForm1::PortComboBoxDropDown(TObject Sender)

{

     TStringList
tslAvailablePorts = new TStringList();





     //... Clear the existing List

     PortComboBox->Items->Clear();



     CommPort->GetComPortNames(tslAvailablePorts);

     PortComboBox->Items->AddStrings(tslAvailablePorts);

}



void __fastcall TForm1::PortComboBoxChange(TObject *Sender)

{

     CommPort->DeviceName = PortComboBox->Text;

     CommPort->Baudrate = br115200;

     CommPort->Databits = db8;

     CommPort->Parity = paNone;

     CommPort->Stopbits = sb1;





     //... Try to open the comm port

     try

     {

          CommPort->Open();

     }

     catch (...)

     {

          StatusEdit->Text = CommPort->DeviceName + " in use!";

          StatusEdit->Color = clYellow;

     }

}



The above code functions may not be exactly what you want, but demonstrate how to select available comm ports, including the extended ones. This works for me through USB Hubs and USB to TTL adapters.



Steve O.