OS2 World Community Forum
OS/2, eCS & ArcaOS - Technical => Applications => Topic started by: roberto 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
-
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.
-
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?
-
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
-
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
-
Since it has a Prolific 067B:2303 USB-Serial Controller, I agree with Ivan that USBCOM.SYS has to be used.
-
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
-
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.
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
-
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.
/* 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
-
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
-
Which USBCOM.SYS is used? You can try this one: http://hobbes.nmsu.edu/download/pub/os2/system/drivers/serial/usbcomm_pl2303.zip (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.
-
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.
-
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:
/* setup communication mode */
'MODE '||ddName||':9600,N,8,1,TO=ON'
obtaining response
response:
Add the /Z switch to the device driver statement.
DEVICE=C:\OS2\BOOT\USBCOM.SYS /M:1 /N:COM8 /V /Z
The /Z switch is special for PL-2303 and 2 wire communication.
-
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
-
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.
...
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.
-
Hallo Roberto,
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
There are 3 things that you could do:
1. Try the valerius usbcom.sys (http://ecomstation.ru/download/drivers/usb/usbcom-20110818.zip) driver.
2. Try the following MODE command:
/* setup communication mode */
'MODE '||ddName||',,N,8,1'
3. Try without the MODE command.
Regards
-
There are 3 things that you could do:
1. Try the valerius usbcom.sys (http://ecomstation.ru/download/drivers/usb/usbcom-20110818.zip) driver.
The link is dead.
2. Try the following MODE command:
COM8,,N,8,1
Unknown command "COM8"
MODE COM8,,N,8,1
SYS0700: The baud rate 300 is not supported by the serial port hardware.
At this point I can think of other possible solutions:
1- Open-close the port with rxusbcalls, and send the commands.The usbcalls work well.
2- Buy a USB cable to rs232, and connect it with two cables to the board. As David proposes. But it is possible that the converter cable has another 2303.
3- Use it as paperweights, hahaha.
I appreciate your opinion.
Saludos
Saludos
-
The link isn't dead because I just downloaded it (now attached here just in case your ISP is blocking you).
Edit:
I still think you should try with a 5 volt power supply as well. We have a client that uses similar boards and they refuse to work unless there is a separate 5v supply.
-
Ivan , Thanks for the file. After donwload your file, the link works well.
With this driver:usbcom-20110818.zip
[D:\usbreles]mode com8
SYS0021: The drive is not ready.
[D:\usbreles]MODE COM8:110,N,8,1,TO=ON
SYS0020: The system cannot find the device specified.
NOTREADY:20 Device driver COM8 currently in use. Please try later.
After that I modifi config.sys to default usbcom.sys /V
And show COM1 in charge, but the same error in com1
The power supply is on and with voltage in all tests.
Saludos
-
If you're planning on buying ArcaOS, just wait till the end of the month as it ships with a usbcom.sys that should work for you, otherwise I guess you need an Arca Noae subscription
-
Another thing that might be the problem.
All the computers that we manage that are using USB com port units also have, and load, the standard com.sys driver.
I don't know if this is necessary, it was there when we imaged the disk for these units and all we did was add the usbcom.sys when the new motherboards no longer has normal com ports.
-
the new motherboards no longer has normal com ports.
[pedantic]Only the connector is missing. Or, in the case of some portable computers, the connector looks like a docking station connector. A port replicator will replicate an existing port.[/pedantic]. Of course USB will have been a desktop's reasonable and efficient alternative for soldering, and so on.
Just pointing out that the port will still be there, so users of such a "normal" serial connector don't always have to throw away their devices or debuggers.
-
<even more pedantic>Many of the new boards don't even have the header in the board any more. Those that do we solder a set of pins in place that allow us to plug in standard ports.</even more pedantic> All said with a big smile.
Unfortunately, the manufacturers are headed in the direction of not having the UART on the boards now so everything has to be USB (Intel I'm looking at you).
-
All said with a big smile.
Finally someone with a little humor! It is also good to laugh. jajaja
Dave, I can wait for the new Arcanoae version.
Saludos
-
Hallo Roberto,
At this point I can think of other possible solutions:
1- Open-close the port with rxusbcalls, and send the commands.The usbcalls work well.
2- Buy a USB cable to rs232, and connect it with two cables to the board. As David proposes. But it is possible that the converter cable has another 2303.
3- Use it as paperweights, hahaha.
I appreciate your opinion.
I would go for option 1 first.
So I prepared some rexx code that, to begin with, tries to get the current settings of baudrate, stopbits, parity and databits and to set these to 9600,N,8,1.
For this to work you need to rem out the usbcom.sys device driver statement in config.sys.
I modified Code Snippets taken from the "USBCALLS - REXX/2 Reference Guide".
/* add UsbLoadFuncs */
rc = RxFuncAdd('UsbLoadFuncs','usbcalls','UsbLoadFuncs')
say '+UsbLoadFuncs(),RC=0x'd2x(rc)
/* invoke UsbLoadFuncs */
rc = ('' <> UsbLoadFuncs())
say '*UsbLoadFuncs(),RC=0x'b2x(rc)
/* drop UsbLoadFuncs */
rc = RxFuncDrop('UsbLoadFuncs')
say '-UsbLoadFuncs(),RC=0x'd2x(rc)
/* invoke RxUsbOpen */
drop Handle /* receives device handle */
EnumDevice=0 /* accept any free device */
idVendor=x2d(067B) /* vendor identifier */
idProduct=x2d(2303) /* product identifier */
bcdDevice=x2d(0300) /* device release number */
rc = RxUsbOpen(Handle,EnumDevice,idVendor,idProduct,bcdDevice)
say '*RxUsbOpen(),RC=0x'd2x(rc)
/* invoke RxUsbDeviceSetConfiguration */
Config=1 /* configuration value to be set */
rc = RxUsbDeviceSetConfiguration(Handle,Config)
say '*RxUsbDeviceSetConfiguration(),RC=0x'd2x(rc)
/* invoke RxUsbCtrlMessage device-to-host */
drop Data /* receives string of data bytes read */
RequestType=x2d(A1); Request=x2d(21) /* GetLineCoding interface class */
Value=x2d(0000); Index=x2d(0000); NumBytes=7; Timeout=8000; /* interface 0 */
rc = RxUsbCtrlMessage(Handle,RequestType,Request,Value,Index,NumBytes,Data,Timeout)
say '*RxUsbCtrlMessage(),RC=0x'd2x(rc)
if (rc = 0) then do
say ' BaudRate:' c2x(reverse(substr(Data,1,4)))
say ' StopBits:' c2x(substr(Data,5,1))
say ' ParyType:' c2x(substr(Data,6,1))
say ' DataBits:' c2x(substr(Data,7,1))
end
/* invoke RxUsbCtrlMessage host-to-device */
Data=x2c(80250000 00 00 08) /* 9600,N,8,1 */
RequestType=x2d(21); Request=x2d(20) /* SetLineCoding interface class */
Value=x2d(0000); Index=x2d(0000); drop NumBytes; Timeout=8000; /* interface 0 */
rc = RxUsbCtrlMessage(Handle,RequestType,Request,Value,Index,NumBytes,Data,Timeout)
say '*RxUsbCtrlMessage(),RC=0x'd2x(rc)
if (rc = 0) then do
say ' BaudRate:' c2d(reverse(substr(Data,1,4)))
say ' StopBits:' c2d(substr(Data,5,1))
say ' ParyType:' c2d(substr(Data,6,1))
say ' DataBits:' c2d(substr(Data,7,1))
end
/* invoke RxUsbClose */
rc = RxUsbClose(Handle)
say '*RxUsbClose(),RC=0x'd2x(rc)
/* add UsbDropFuncs */
rc = RxFuncAdd('UsbDropFuncs','usbcalls','UsbdropFuncs')
say '+UsbDropFuncs(),RC=0x'd2x(rc)
/* invoke UsbDropFuncs */
rc = ('' <> UsbDropFuncs())
say '*UsbDropFuncs(),RC=0x'b2x(rc)
/* drop UsbDropFuncs */
rc = RxFuncDrop('UsbDropFuncs')
say '-UsbDropFuncs(),RC=0x'd2x(rc)
-
The return:
[d:\usbreles]urwim.cmd
+UsbLoadFuncs(),RC=0x0
*UsbLoadFuncs(),RC=0x0
-UsbLoadFuncs(),RC=0x0
*RxUsbOpen(),RC=0x0
*RxUsbDeviceSetConfiguration(),RC=0x0
*RxUsbCtrlMessage(),RC=0x0
BaudRate: 00002580
StopBits: 00
ParyType: 00
DataBits: 00
*RxUsbCtrlMessage(),RC=0x0
BaudRate: 9600
StopBits: 0
ParyType: 0
DataBits: 8
*RxUsbClose(),RC=0x0
+UsbDropFuncs(),RC=0x0
*UsbDropFuncs(),RC=0x0
-UsbDropFuncs(),RC=0x0
End return ----------
I have doubts, if I should include this line, because the pcboard says to speak English (usbtest.cmd), and I have the default system in code page 850.
/* load all RexxUtil functions */
Call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
Call SysLoadFuncs
rc=SysSetProcessCodePage(437)
Saludos
-
Hallo Roberto,
I have doubts, if I should include this line, because the pcboard says to speak English (usbtest.cmd), and I have the default system in code page 850.
/* load all RexxUtil functions */
Call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
Call SysLoadFuncs
rc=SysSetProcessCodePage(437)
That is not necessary. I think It only relates to the string descriptors.
The posted results are so far so good. Therefore I have rearranged and extended the script.
It sets DTR and RTS and tries to bulk write 8 bytes of 0x50 and to bulk read any response.
/* add UsbLoadFuncs */
rc = RxFuncAdd('UsbLoadFuncs','usbcalls','UsbLoadFuncs')
say '+UsbLoadFuncs(),RC=0x'd2x(rc)
/* invoke UsbLoadFuncs */
rc = ('' <> UsbLoadFuncs())
say '*UsbLoadFuncs(),RC=0x'b2x(rc)
/* drop UsbLoadFuncs */
rc = RxFuncDrop('UsbLoadFuncs')
say '-UsbLoadFuncs(),RC=0x'd2x(rc)
/* invoke RxUsbOpen */
drop Handle /* receives device handle */
EnumDevice=0 /* accept any free device */
idVendor=x2d(067B) /* vendor identifier */
idProduct=x2d(2303) /* product identifier */
bcdDevice=x2d(0300) /* device release number */
rc = RxUsbOpen(Handle,EnumDevice,idVendor,idProduct,bcdDevice)
say '*RxUsbOpen(),RC=0x'd2x(rc)
/* invoke RxUsbDeviceSetConfiguration */
Config=1 /* configuration value to be set */
rc = RxUsbDeviceSetConfiguration(Handle,Config)
say '*RxUsbDeviceSetConfiguration(),RC=0x'd2x(rc)
/* invoke RxUsbCtrlMessage host-to-device */
Data=x2c(80250000 00 00 08) /* 9600,1,N,8 */
RequestType=x2d(21); Request=x2d(20) /* SetLineCoding interface class */
Value=x2d(0000); Index=x2d(0000); drop NumBytes; Timeout=8000; /* interface 0 */
rc = RxUsbCtrlMessage(Handle,RequestType,Request,Value,Index,NumBytes,Data,Timeout)
say '*RxUsbCtrlMessage(),RC=0x'd2x(rc)
if (rc = 0) then do
say ' BaudRate:' c2d(reverse(substr(Data,1,4)))
say ' StopBits:' c2d(substr(Data,5,1))
say ' ParyType:' c2d(substr(Data,6,1))
say ' DataBits:' c2d(substr(Data,7,1))
end
/* invoke RxUsbCtrlMessage device-to-host */
drop Data /* receives string of data bytes read */
RequestType=x2d(A1); Request=x2d(21) /* GetLineCoding interface class */
Value=x2d(0000); Index=x2d(0000); NumBytes=7; Timeout=8000; /* interface 0 */
rc = RxUsbCtrlMessage(Handle,RequestType,Request,Value,Index,NumBytes,Data,Timeout)
say '*RxUsbCtrlMessage(),RC=0x'd2x(rc)
if (rc = 0) then do
say ' BaudRate:' c2d(reverse(substr(Data,1,4)))
say ' StopBits:' c2d(substr(Data,5,1))
say ' ParyType:' c2d(substr(Data,6,1))
say ' DataBits:' c2d(substr(Data,7,1))
end
/* invoke RxUsbCtrlMessage host-to-device */
RequestType=x2d(21); Request=x2d(22) /* SetControlLineState interface class */
Value=x2d(0300); Index=x2d(0000); drop NumBytes; Timeout=8000; /* DTR=ON,RTS=ON,interface 0 */
rc = RxUsbCtrlMessage(Handle,RequestType,Request,Value,Index,NumBytes,,Timeout)
say '*RxUsbCtrlMessage(),RC=0x'd2x(rc)
/* invoke RxUsbBulkWrite */
drop NumBytes /* receives number of data bytes written */
Endpoint=2; AltSetting=0; Data=copies(x2c(50),8); Timeout=8000
rc = RxUsbBulkWrite(Handle,Endpoint,AltSetting,NumBytes,Data,Timeout)
say '*RxUsbBulkWrite(),RC=0x'd2x(rc)
/* invoke RxUsbBulkRead */
drop Data /* receives string of data bytes read */
Endpoint=128+3; AltSetting=0; NumBytes=8; Timeout=8000
rc = RxUsbBulkRead(Handle,Endpoint,AltSetting,NumBytes,Data,Timeout)
say '*RxUsbBulkRead(),RC=0x'd2x(rc)
if (rc = 0) then do
say ' Data:' c2x(Data)
end
/* invoke RxUsbClose */
rc = RxUsbClose(Handle)
say '*RxUsbClose(),RC=0x'd2x(rc)
/* add UsbDropFuncs */
rc = RxFuncAdd('UsbDropFuncs','usbcalls','UsbdropFuncs')
say '+UsbDropFuncs(),RC=0x'd2x(rc)
/* invoke UsbDropFuncs */
rc = ('' <> UsbDropFuncs())
say '*UsbDropFuncs(),RC=0x'b2x(rc)
/* drop UsbDropFuncs */
rc = RxFuncDrop('UsbDropFuncs')
say '-UsbDropFuncs(),RC=0x'd2x(rc)
Regards
-
[d:\usbreles]urwim2
+UsbLoadFuncs(),RC=0x0
*UsbLoadFuncs(),RC=0x0
-UsbLoadFuncs(),RC=0x0
*RxUsbOpen(),RC=0x0
*RxUsbDeviceSetConfiguration(),RC=0x0
*RxUsbCtrlMessage(),RC=0x0
BaudRate: 9600
StopBits: 0
ParyType: 0
DataBits: 8
*RxUsbCtrlMessage(),RC=0x0
BaudRate: 9600
StopBits: 0
ParyType: 0
DataBits: 8
*RxUsbCtrlMessage(),RC=0x0
*RxUsbBulkWrite(),RC=0x0
*RxUsbBulkRead(),RC=0x280
*RxUsbClose(),RC=0x0
+UsbDropFuncs(),RC=0x0
*UsbDropFuncs(),RC=0x0
-UsbDropFuncs(),RC=0x0
-
I think that this file can help you, is the result from usbwrite.cmd, I attach.
I do not undertand endpoint=128+3
And *RxUsbBulkRead(),RC=0x280
the x280 when I wait for AC
By now is nice.
-
Hi Roberto,
I think that this file can help you, is the result from usbwrite.cmd, I attach.
I have that information already, but thanks anyway.
I do not undertand endpoint=128+3
endpoint=128+3 is the same as endpoint=x2d(83) and is the bulk input endpoint. The direction bit is 0x80 (hexadecimal) which is 128 (decimal) for input.
And *RxUsbBulkRead(),RC=0x280
the x280 when I wait for AC
The 0x280 is ERROR_TIMEOUT. The RxBulkRead waited 8 seconds for the 8 byte input. Please modify it to ask for only 1 byte. Perhaps that will work then.
By now is nice.
It could be better though.
Edited: I am now looking in pl2303.c from linux and I see that some vendor specific requests are required.
It is time for dinner now. After some study I will hopefully reply tomorrow.
Regards
-
Hallo Roberto,
I have added the vendor specific requests that seem to be required.
/* add UsbLoadFuncs */
rc = RxFuncAdd('UsbLoadFuncs','usbcalls','UsbLoadFuncs')
say '+UsbLoadFuncs(),RC=0x'd2x(rc)
/* invoke UsbLoadFuncs */
rc = ('' <> UsbLoadFuncs())
say '*UsbLoadFuncs(),RC=0x'b2x(rc)
/* drop UsbLoadFuncs */
rc = RxFuncDrop('UsbLoadFuncs')
say '-UsbLoadFuncs(),RC=0x'd2x(rc)
/* invoke RxUsbOpen */
drop Handle /* receives device handle */
EnumDevice=0 /* accept any free device */
idVendor=x2d(067B) /* vendor identifier */
idProduct=x2d(2303) /* product identifier */
bcdDevice=x2d(0300) /* device release number */
rc = RxUsbOpen(Handle,EnumDevice,idVendor,idProduct,bcdDevice)
say '*RxUsbOpen(),RC=0x'd2x(rc)
/* invoke RxUsbDeviceSetConfiguration */
Config=1 /* configuration value to be set */
rc = RxUsbDeviceSetConfiguration(Handle,Config)
say '*RxUsbDeviceSetConfiguration(),RC=0x'd2x(rc)
/* vendor specific initialization */
call VendorGetMagic x2d(8484) x2d(0000)
call VendorSetMagic x2d(0404) x2d(0000)
call VendorGetMagic x2d(8484) x2d(0000)
call VendorGetMagic x2d(8383) x2d(0000)
call VendorGetMagic x2d(8484) x2d(0000)
call VendorSetMagic x2d(0404) x2d(0001)
call VendorGetMagic x2d(8484) x2d(0000)
call VendorGetMagic x2d(8383) x2d(0000)
call VendorSetMagic x2d(0000) x2d(0001)
call VendorSetMagic x2d(0001) x2d(0000)
call VendorSetMagic x2d(0002) x2d(0044)
/* invoke RxUsbCtrlMessage host-to-device */
Data=x2c(80250000 00 00 08) /* 9600,1,N,8 */
RequestType=x2d(21); Request=x2d(20) /* SetLineCoding interface class */
Value=x2d(0000); Index=x2d(0000); drop NumBytes; Timeout=100; /* interface 0 */
rc = RxUsbCtrlMessage(Handle,RequestType,Request,Value,Index,NumBytes,Data,Timeout)
say '*RxUsbCtrlMessage(SetLineCoding),RC=0x'd2x(rc)
if (rc = 0) then do
say ' BaudRate:' c2d(reverse(substr(Data,1,4)))
say ' StopBits:' c2d(substr(Data,5,1))
say ' ParyType:' c2d(substr(Data,6,1))
say ' DataBits:' c2d(substr(Data,7,1))
end
/* invoke RxUsbCtrlMessage device-to-host */
drop Data /* receives string of data bytes read */
RequestType=x2d(A1); Request=x2d(21) /* GetLineCoding interface class */
Value=x2d(0000); Index=x2d(0000); NumBytes=7; Timeout=100; /* interface 0 */
rc = RxUsbCtrlMessage(Handle,RequestType,Request,Value,Index,NumBytes,Data,Timeout)
say '*RxUsbCtrlMessage(GetLineCoding),RC=0x'd2x(rc)
if (rc = 0) then do
say ' BaudRate:' c2d(reverse(substr(Data,1,4)))
say ' StopBits:' c2d(substr(Data,5,1))
say ' ParyType:' c2d(substr(Data,6,1))
say ' DataBits:' c2d(substr(Data,7,1))
end
/* invoke RxUsbBulkWrite */
drop NumBytes /* receives number of data bytes written */
Endpoint=2; AltSetting=0; Data=copies(x2c(50),8); Timeout=8000
rc = RxUsbBulkWrite(Handle,Endpoint,AltSetting,NumBytes,Data,Timeout)
say '*RxUsbBulkWrite(),RC=0x'd2x(rc)
/* invoke RxUsbBulkRead */
drop Data /* receives string of data bytes read */
Endpoint=128+3; AltSetting=0; NumBytes=1; Timeout=8000
rc = RxUsbBulkRead(Handle,Endpoint,AltSetting,NumBytes,Data,Timeout)
say '*RxUsbBulkRead(),RC=0x'd2x(rc)
if (rc = 0) then do
say ' Data:' c2x(Data)
end
/* invoke RxUsbClose */
rc = RxUsbClose(Handle)
say '*RxUsbClose(),RC=0x'd2x(rc)
/* add UsbDropFuncs */
rc = RxFuncAdd('UsbDropFuncs','usbcalls','UsbdropFuncs')
say '+UsbDropFuncs(),RC=0x'd2x(rc)
/* invoke UsbDropFuncs */
rc = ('' <> UsbDropFuncs())
say '*UsbDropFuncs(),RC=0x'b2x(rc)
/* drop UsbDropFuncs */
rc = RxFuncDrop('UsbDropFuncs')
say '-UsbDropFuncs(),RC=0x'd2x(rc)
return
VendorGetMagic:
parse arg Value Index
/* invoke RxUsbCtrlMessage device-to-host */
RequestType=x2d(C0); Request=x2d(01); drop Data;
rc = RxUsbCtrlMessage(Handle,RequestType,Request,Value,Index,1,Data,100);
say '*RxUsbCtrlMessage(VendorGetMagic),RC=0x'd2x(rc);
return
VendorSetMagic:
parse arg Value Index
/* invoke RxUsbCtrlMessage host-to-device */
RequestType=x2d(40); Request=x2d(01); drop NumBytes;
rc = RxUsbCtrlMessage(Handle,RequestType,Request,Value,Index,NumBytes,,100);
say '*RxUsbCtrlMessage(VendorSetMagic),RC=0x'd2x(rc);
return
Regards
-
You are a phenomenon !!!!,
Anyway I comment:
The first time I ran it on the screen gave me this error
*RxUsbBulkRead(),RC=0x8050
The second time I run it but send to file, and give me error:
**RxUsbBulkRead(),RC=0x280
After this I unplug and plug the usb and give me this error:
*RxUsbBulkRead(),RC=0x0
Data: AC
But only run well if I send to file, similar a urwin.cmd >mifile.txt
Now is nice.
Saludos
-
Hi Roberto,
The first time I ran it on the screen gave me this error
*RxUsbBulkRead(),RC=0x8050
The second time I run it but send to file, and give me error:
**RxUsbBulkRead(),RC=0x280
The RC=0x8050 means ERROR_HALTED_BABBLE. The device unexpectedly transmitted data to the host.
The RC=0x280 as you already know means timeout. The device did not transmit data to the host.
After this I unplug and plug the usb and give me this error:
*RxUsbBulkRead(),RC=0x0
Data: AC
But only run well if I send to file, similar a urwin.cmd >mifile.txt
There is obviously some timing issue. You might try and test with sending only 1 data byte with RxUsbBulkWrite.
Now is nice.
Yes. Nice. We are getting there. Tomorrow I will put in some sleep instructions and see where that gets us.
-
There is obviously some timing issue. You might try and test with sending only 1 data byte with RxUsbBulkWrite.
I could not see any improvement by modifying this value.
But if I improve disconnecting the power to the plate, restoring the laptop, and connecting the usb after restoration worked well. I even added it's rest of code and moved the relays.
It may be that the power supply is not stabilized, and this circuit requires more precision in the voltage.
I have another problem with this laptop, and I have to wait for 16 minutes to 20 minutes, to restart it. If I do not do this, the OS / 2 turns off the laptop. This happens to me with any of the OS / 2 partitions, but not if I boot w10.
The only doubt I have is the numbering of relays. And the possible combination of starting two or more relays at the same time.
-
Hallo Roberto,
There is obviously some timing issue. You might try and test with sending only 1 data byte with RxUsbBulkWrite.
I could not see any improvement by modifying this value.
But if I improve disconnecting the power to the plate, restoring the laptop, and connecting the usb after restoration worked well. I even added it's rest of code and moved the relays.
It may be that the power supply is not stabilized, and this circuit requires more precision in the voltage.
I have seen reports on the internet that external power needed to be soldered to the power pin of the serial connector:
"Power the relay from the header pin instead of the power jack. There appears to be a big voltage drop on the power jack."
The only doubt I have is the numbering of relays. And the possible combination of starting two or more relays at the same time.
I prepared some example code that might help you out.
/* relay manipulation */
relays = x2c(b2x('11111111'));
say 'start with relays 1,2,3,4,5,6,7,8 off:' x2b(c2x(relays));
/* initialize relay switch masks */
r1off = x2c(b2x('00000001')); r1on = bitxor(r1off,relays);
r2off = x2c(b2x('00000010')); r2on = bitxor(r2off,relays);
r3off = x2c(b2x('00000100')); r3on = bitxor(r3off,relays);
r4off = x2c(b2x('00001000')); r4on = bitxor(r4off,relays);
r5off = x2c(b2x('00010000')); r5on = bitxor(r5off,relays);
r6off = x2c(b2x('00100000')); r6on = bitxor(r6off,relays);
r7off = x2c(b2x('01000000')); r7on = bitxor(r7off,relays);
r8off = x2c(b2x('10000000')); r8on = bitxor(r8off,relays);
/* relay switch example */
relays = bitand(relays,r1on);
relays = bitand(relays,r3on);
relays = bitand(relays,r5on);
relays = bitand(relays,r7on);
say 'now relays 1,3,5,7 on and 2,4,6,8,off:' x2b(c2x(relays));
/* relay switch example */
relays = bitor(relays,r1off);
relays = bitand(relays,r2on);
relays = bitor(relays,r3off);
relays = bitand(relays,r4on);
relays = bitor(relays,r5off);
relays = bitand(relays,r6on);
relays = bitor(relays,r7off);
relays = bitand(relays,r8on);
say 'now relays 1,3,5,7 off and 2,4,6,8,on:' x2b(c2x(relays));
/* relay switch example */
relays = bitor(relays,r8off);
relays = bitor(relays,r6off);
relays = bitor(relays,r4off);
relays = bitor(relays,r2off);
say 'stops with relays 1,2,3,4,5,6,7,8 off:' x2b(c2x(relays));
Regards
-
There is obviously some timing issue. You might try and test with sending only 1 data byte with RxUsbBulkWrite.
I could not see any improvement by modifying this value.
But if I improve disconnecting the power to the plate, restoring the laptop, and connecting the usb after restoration worked well. I even added it's rest of code and moved the relays.
It may be that the power supply is not stabilized, and this circuit requires more precision in the voltage.
I have another problem with this laptop, and I have to wait for 16 minutes to 20 minutes, to restart it. If I do not do this, the OS / 2 turns off the laptop. This happens to me with any of the OS / 2 partitions, but not if I boot w10.
The only doubt I have is the numbering of relays. And the possible combination of starting two or more relays at the same time.
Regarding the laptop powering off; it may be overheating. If so, the latest ACPI from Arca Noae may fix it.
-
Well, I can say, thank you.
Finally I gave a termination to your explanations, which have been very didactic for me.
I have left it so that only one relay can be pressed one by one.
For two reasons, do not overload the pc (being without power supply), and because it is more practical to verify that each relay works on OS / 2.
-
roberto, There is a little bit of information on this site http://www.puntoflotante.net/ICSE014A-MODULE-8-RELAY-SERIAL-PORT-BOLT-18F2550.htm (http://www.puntoflotante.net/ICSE014A-MODULE-8-RELAY-SERIAL-PORT-BOLT-18F2550.htm)
The main point being the comment under Figure 2 regarding the power to the unit.
It appears that it does need an external power supply because on startup it pulls more power than a standard USB port can supply.
-
It appears that it does need an external power supply because on startup it pulls more power than a standard USB port can supply.
Yes, you are right, so in the example I have only put the activation one by one to not overload the computer. Now I have to find an old power supply from a pc, to couple it. Like the ones that a lot of people use for arduinos and rasperripy. But in this case I will put my old laptop.
If you look, the relay plates of one or two relays, do not have the option of external power supply. I understand it's because they do not need it.
Saludos
-
Hallo Wim,
do you think that we will manage to fix USBCOM.SYS so that it will do what you now did with the help of USBCALLS.DLL ?
Obviously, USBCOM.SYS is the proper place to put this, in particular the vendor specific Setup. I remember that David Azariewicz added some specific code which I think he also took from file "pl2303.c" but maybe the vendor specific Setup is not working correctly yet.
Lars
-
Hallo Lars,
Hallo Wim,
do you think that we will manage to fix USBCOM.SYS so that it will do what you now did with the help of USBCALLS.DLL ?
Obviously, USBCOM.SYS is the proper place to put this, in particular the vendor specific Setup. I remember that David Azariewicz added some specific code which I think he also took from file "pl2303.c" but maybe the vendor specific Setup is not working correctly yet.
Lars
I must say that I am not convinced that your current USBCOM.SYS cannot be used to drive the relays. It is my understanding that Roberto did not use an external power supply at that time. May be we did not try hard enough with slight modifications of my original script to get it working. We jumped to using the USBCALLS - REXX/2 External Functions.
I agree that USBCOM.SYS is the proper place to support serial communications thru the various pl2303 chip versions. Browsing the internet I learned that the very same vendor specific code is used again and again when someone supports the pl2303 in his code. It was originally derived from snooping what happens under windows. The actual working is unknown. I think that the VendorGetMagic calls are redundant i.e. the information obtained is not used. May be windows used it to probe what pl2303 version thy are dealing with.
In practice it is impossible to reliably fix USBCOM.SYS without the hardware at hand. Moreover it could break existing support for the various pl2302 hardware that people are currently using.
Wim
-
Yes, you are right, so in the example I have only put the activation one by one to not overload the computer.
That is OK while running but on start up the boards firmware activates ALL of the relays at once. This is where the problem lies because when doing that it tries to draw too much current from the USB port.
All you need for a power supply is one of the 5 volt 1.5 or 2 A phone or tablet chargers which is what we used with a similar board (we made a USB to concentric plug cable to do the job).
-
from file "pl2303.c" but maybe the vendor specific Setup is not working correctly yet.
I read about this chip this can be the problem?:
Warning Notice:
Please be warned that counterfeit (fake) PL-2303HX (Chip Rev A) USB to Serial Controller ICs using Prolific's trademark logo, brandname, and device drivers, were being sold in the China market. Counterfeit IC products show exactly the same outside chip markings but generally are of poor quality and causes Windows driver compatibility issues (Yellow Mark Error Code 10 in Device Manager). We issue this warning to all our customers and consumers to avoid confusion and false purchase.
The web site of Prolific Tech:
http://www.prolific.com.tw/US/ShowProduct.aspx?p_id=225&pcid=41
-
Roberto did not use an external power supply at that time. May be we did not try hard enough with slight modifications of my original script to get it working.
I wanted to clarify, the problem of the two errors that sometimes occur in the starting of the plate.If I keep the circuit with current, I get the feeling that something is not reset, because with current if it does not start the first there is no way to start it.And since I'm a bit of a bitch, I do not want to get up and unplug it. What I do is remove the power-source, and only with the usb, it is easier to unplug and ready.I also need to prove with a source of more quality, in case it may or may not affect it.
what happens uInder windows.
I only tried it twice, the first one worked but it was bad (the reles did not act as expected, but they moved), and the second time could not find the device.
In os / 2 this is working fine, but always after receiving the AC command, which is where in the boot sometimes gives errors x280 and x80 ..
Saludos
-
the problem of the two errors that sometimes occur in the starting of the plate
In the relays.cmd file, I change this two lines and now is work 100% ok.
from this rc = RxUsbCtrlMessage(Handle,RequestType,Request,Value,Index,1,Data,100);
to rc = RxUsbCtrlMessage(Handle,RequestType,Request,Value,Index,1,Data,1000);
and in
from rc = RxUsbCtrlMessage(Handle,RequestType,Request,Value,Index,NumBytes,,100);
to rc = RxUsbCtrlMessage(Handle,RequestType,Request,Value,Index,NumBytes,,1000);
The power supply has no influence at all. The important thing is to disconnect it (from the power supply, like the usb) before starting the usbrelays.cmd
Saludos
-
the problem of the two errors that sometimes occur in the starting of the plate
In the relays.cmd file, I change this two lines and now is work 100% ok.
from this rc = RxUsbCtrlMessage(Handle,RequestType,Request,Value,Index,1,Data,100);
to rc = RxUsbCtrlMessage(Handle,RequestType,Request,Value,Index,1,Data,1000);
and in
from rc = RxUsbCtrlMessage(Handle,RequestType,Request,Value,Index,NumBytes,,100);
to rc = RxUsbCtrlMessage(Handle,RequestType,Request,Value,Index,NumBytes,,1000);
The power supply has no influence at all. The important thing is to disconnect it (from the power supply, like the usb) before starting the usbrelays.cmd
Saludos
Thank you Roberto.
To Lars - This is something to update in the source of USBCOM.SYS as well. In COMSTRAT.C the VendorRW routine line 1411 increase the timeout value from 100 to 1000.
-
Hi Wim,
done, see SVN rev 1716. Should I ever find the time I am going to get rid of the blocking and properly implement this as asynchronous notification (as all the other commands are treated).
Lars