Author Topic: Can I use a usb port as a com-port?  (Read 3976 times)

roberto

  • Sr. Member
  • ****
  • Thank You
  • -Given: 14
  • -Receive: 6
  • Posts: 330
    • View Profile
Can I use a usb port as a com-port?
« on: January 28, 2017, 11:53:43 am »
The case is that I wanted to use a circuit board with 8 relays that has a usb connection.
And I was thinking of using it with the rxcom.dll with rexx.

Someone can tell me if I can or not? Or if I would have to install something to make it work.?
Thanks



ivan

  • Hero Member
  • *****
  • Thank You
  • -Given: 0
  • -Receive: 24
  • Posts: 658
    • View Profile
Re: Can I use a usb port as a com-port?
« Reply #1 on: January 28, 2017, 02:24:06 pm »
For a start you need USBCOM.SYS loaded with the other USB drivers.  Then it will depend on how the relay board talks to the interface you are using.

We have clients using serial to USB adapters for machinery control and in all cases they appear as standard serial ports so the original OS/2 serial software still works.

Wim Brul

  • Full Member
  • ***
  • Thank You
  • -Given: 3
  • -Receive: 28
  • Posts: 133
    • View Profile
    • Wim's home page
Re: Can I use a usb port as a com-port?
« Reply #2 on: January 28, 2017, 02:59:50 pm »
Quote
The case is that I wanted to use a circuit board with 8 relays that has a usb connection.

Since it has a usb connection, I would plug it into a usb port and control it through the usbcalls rexx interface functions.

Which circuit board is it? What documenmtation do you have?

roberto

  • Sr. Member
  • ****
  • Thank You
  • -Given: 14
  • -Receive: 6
  • Posts: 330
    • View Profile
Re: Can I use a usb port as a com-port?
« Reply #3 on: January 28, 2017, 06:23:52 pm »
For a start you need USBCOM.SYS loaded with the other USB drivers. 
If you are right, the first thing is to include it in the config.sys with
DEVICE = c: \ OS2 \ BOOT \ USBCOM.SYS / V

thanks

roberto

  • Sr. Member
  • ****
  • Thank You
  • -Given: 14
  • -Receive: 6
  • Posts: 330
    • View Profile
Re: Can I use a usb port as a com-port?
« Reply #4 on: January 28, 2017, 06:31:59 pm »
Which circuit board is it? What documenmtation do you have?
The board is ICSE014A from http://www.icstation.com/icstation-channel-micro-relay-module-icse014a-p-5185.html
 2)Serial port using method

These modules can use the serial port to connect with other communication devices. These modules can receive the Single-byte instruction from the upper monitor.
Upper Monitor          0x50        0x51
ICSE012A          0xAB
ICSE013A          0xAD
ICSE014A          0xAC

These modules will work normally after they receive the "0X51" instruction. The bytes which these modules receive can control the modules directly and every singly byte control one channel of the module( "0" means start, "1"means stop).
The usb show that is a :
<<< Device Description >>>
 Type            : 01
 USB Rev         : 110
 Class           : Reserved (0)
 Subclass        : Reserved (0)
 Protocol        : Reserved (0)
  Device Information is defined at interface Level
 Max. packetsize : 40
 Vendor  ID      : 067B
 Product ID      : 2303
 Device Release# : 0300
 Strings:
  Manufacturer Name : Prolific Technology Inc.
  Product Name      : USB-Serial Controller
  Serial number     : Not implemented
 Number of Configurations : 1

 Configuration 0 :
  Lenght     : 39
  Name       : <NONE>
  Value      : 1
  Attributes : 0x80
  Power      : 100 mA
  Interfaces : 1

  Interface 0
   Alt Setting : 0
   Name        : <NONE>
   Class       : Vendor specific
   SubClass    : Vendor specific
   Protocol    : Vendor specific
   Endpoints   : 3

   Endpoint 0:
    Address     : 81
    Attributes  : 03
    Packetsize  : 000A
    Interval    : 1

   Endpoint 1:
    Address     : 02
    Attributes  : 02
    Packetsize  : 0040
    Interval    : 0

   Endpoint 2:
    Address     : 83
    Attributes  : 02
    Packetsize  : 0040
    Interval    : 0

Saludos


Wim Brul

  • Full Member
  • ***
  • Thank You
  • -Given: 3
  • -Receive: 28
  • Posts: 133
    • View Profile
    • Wim's home page
Re: Can I use a usb port as a com-port?
« Reply #5 on: January 28, 2017, 08:41:05 pm »
Since it has a Prolific 067B:2303 USB-Serial Controller, I agree with Ivan that USBCOM.SYS has to be used.

Wim Brul

  • Full Member
  • ***
  • Thank You
  • -Given: 3
  • -Receive: 28
  • Posts: 133
    • View Profile
    • Wim's home page
Re: Can I use a usb port as a com-port?
« Reply #6 on: March 13, 2017, 12:01:44 pm »
Hallo Roberto,

DEVICE=C:\OS2\BOOT\USBCOM.SYS /M:1 /N:COM8 /V

Did you succeed in controlling your relay board?

What does MODE COM8 report?

Regards

roberto

  • Sr. Member
  • ****
  • Thank You
  • -Given: 14
  • -Receive: 6
  • Posts: 330
    • View Profile
Re: Can I use a usb port as a com-port?
« Reply #7 on: March 13, 2017, 07:23:30 pm »
Did you succeed in controlling your relay board?
No, It is a personal project of little importance. But if I engaged in communications I would starve.
Quote
What does MODE COM8 report?

[d:\usbreles]mode com8
baud     = 300                    parity   = NONE
databits = 8                      stopbits = 1
TO       = OFF                    XON      = OFF
IDSR     = OFF                    ODSR     = OFF
OCTS     = OFF                    DTR      = ON
RTS      = ON                     BUFFER   = N/A
Saludos

Wim Brul

  • Full Member
  • ***
  • Thank You
  • -Given: 3
  • -Receive: 28
  • Posts: 133
    • View Profile
    • Wim's home page
Re: Can I use a usb port as a com-port?
« Reply #8 on: March 14, 2017, 04:49:56 pm »
Hi Roberto,

I do not have that relay board, but may be the following code will be of help. Try it and see what it does.

Code: [Select]
/* write/read to/from relay device */
rc=RxFuncAdd('SysSleep','RexxUtil','SysSleep')

/* set com port*/
ddName = 'COM8'

/* protect the file system from inadvertent access */
if stream(ddName,'command','query exists') \= '\DEV\' || ddName
then do
  say 'ERROR: The device driver' ddName 'does not exist!'
  /* wait */
  '@pause'
  exit
  end

/* setup communication mode */
'MODE '||ddName||':9600,N,8,1,BUFFER=OFF,TO=ON'

/* acquire the device driver */
rc=stream(ddName,'command','open')
if rc \= 'READY:'
then do
  say rc 'Device driver' ddName 'currently in use. Please try later.'
  /* wait */
  '@pause'
  exit
  end

/* send 0x50 command */
say 'sending 0x50 command'
rc = charout(ddName,x2c(50))
call SysSleep(0.030)

/* obtain response */
say 'obtaining response'
response = charin(ddName,,1)
say 'response: 'c2x(response)
call SysSleep(0.030)

/* send 0x51 command */
say 'sending 0x51 command'
rc = charout(ddName,x2c(51))
call SysSleep(0.030)

/* switch relays off */
say 'sending 0xFF control'
rc = charout(ddName,x2c(FF))
call SysSleep(0.030)

/* switch relay 1 on */
say 'sending 0xFE control'
rc = charout(ddName,x2c(FE))
call SysSleep(0.030)

/* wait 5 seconds */
say 'waiting 5 seconds'
call SysSleep(5)

/* switch relays off */
say 'sending 0xFF control'
rc = charout(ddName,x2c(FF))
call SysSleep(0.030)

/* release the device driver */
rc=stream(ddName,'command','close')

Regards

roberto

  • Sr. Member
  • ****
  • Thank You
  • -Given: 14
  • -Receive: 6
  • Posts: 330
    • View Profile
Re: Can I use a usb port as a com-port?
« Reply #9 on: March 14, 2017, 10:38:31 pm »
Thank you very much, it is more than I expected.
But it does not work, :

[d:\usbreles]reles
MODE COM8:9600,N,8,1,BUFFER=OFF,TO=ON
The MODE parameter BUFFER= is not supported by this COM port.
sending 0x50 command
obtaining response
response:
sending 0x51 command
sending 0xFF control
sending 0xFE control
waiting 5 seconds
sending 0xFF control

Saludos

Andreas Kohl

  • Full Member
  • ***
  • Thank You
  • -Given: 6
  • -Receive: 9
  • Posts: 214
    • View Profile
    • warpserver.de
Re: Can I use a usb port as a com-port?
« Reply #10 on: March 14, 2017, 11:42:14 pm »
Which USBCOM.SYS is used? You can try this one: http://hobbes.nmsu.edu/download/pub/os2/system/drivers/serial/usbcomm_pl2303.zip

It can complicated and time consuming to establish reliable communication when lousy USB to serial converters are involved. So it's a better option to use a real serial cards or a network connection to a terminal server.

ivan

  • Hero Member
  • *****
  • Thank You
  • -Given: 0
  • -Receive: 24
  • Posts: 658
    • View Profile
Re: Can I use a usb port as a com-port?
« Reply #11 on: March 14, 2017, 11:54:22 pm »
A point I missed.  How are you powering this board, USB only or a 5 volt power pack?  USB only may not work - it depends on how much current the supplying port can output.

Wim Brul

  • Full Member
  • ***
  • Thank You
  • -Given: 3
  • -Receive: 28
  • Posts: 133
    • View Profile
    • Wim's home page
Re: Can I use a usb port as a com-port?
« Reply #12 on: March 15, 2017, 12:25:48 pm »
Quote
MODE COM8:9600,N,8,1,BUFFER=OFF,TO=ON
The MODE parameter BUFFER= is not supported by this COM port.

Use the following code instead:

Code: [Select]
/* setup communication mode */
'MODE '||ddName||':9600,N,8,1,TO=ON'

Quote
obtaining response
response:

Add the /Z switch to the device driver statement.

Code: [Select]
DEVICE=C:\OS2\BOOT\USBCOM.SYS /M:1 /N:COM8 /V /Z

The /Z switch is special for PL-2303 and 2 wire communication.

roberto

  • Sr. Member
  • ****
  • Thank You
  • -Given: 14
  • -Receive: 6
  • Posts: 330
    • View Profile
Re: Can I use a usb port as a com-port?
« Reply #13 on: March 15, 2017, 11:49:12 pm »
Ivan, I have checked that the power supply actually has voltage 5.44 volt

Andreas, with usbcom.sys special for 2303 ver1.1  the same error that with usbcom.sys 10.215

Win, with usbcom.sys 10.215

MODE COM8:110,N,8,1,TO=ON
SYS0700: The baud rate 110 is not supported by the serial port hardware.

 I test with 110,150,300,9600,57600 and in all cases the same error.
Saludos

Dave Yeo

  • Hero Member
  • *****
  • Thank You
  • -Given: 8
  • -Receive: 91
  • Posts: 1176
    • View Profile
Re: Can I use a usb port as a com-port?
« Reply #14 on: March 16, 2017, 12:10:35 am »
Ivan, I have checked that the power supply actually has voltage 5.44 volt

Andreas, with usbcom.sys special for 2303 ver1.1  the same error that with usbcom.sys 10.215

Win, with usbcom.sys 10.215

MODE COM8:110,N,8,1,TO=ON
SYS0700: The baud rate 110 is not supported by the serial port hardware.

 I test with 110,150,300,9600,57600 and in all cases the same error.
Saludos

I have a modem that calls itself a USB modem but it actually has a serial port and a USB port. The USB port is hooked up to a PL2303 USB to Serial converter. It never worked with any of the drivers I tried until one of David's (Arca Noae?) builds. Here's a quote from the changelog. Not sure if Lars' USB builds have the fix.
Quote
...
v.11.05 12-Sep-2013-David Azarewicz
 Implemented ISO changes from Lars' branch.
 Added some class drivers to the distribution.
 Fixed PL2303 support in USBCOM driver.
...

It was only after installing that version that the USB [PL2303] modem worked. Haven't tried it for a while as this computer has a serial port and I'm using a USR Sporster.