> Il 09/09/2015 17:20, Grant Edwards ha scritto:
>> On 2015-09-09, pozz <pozzugno@gmail.com> wrote:
>>
>>> Now I'm searching a software running on Windows machine that opens a
>>> number of COM ports and forward every byte received from one port to all
>>> the other ports. In this way I can simulate a multi-drop bus.
>>> It should be a RS232 virtual hub.
>>>
>>> +----+ +-----------+ +----+
>>> | V1 |(COM7)<--->(COM8)| RS232_HUB |(COM9)<--->(COM10)| V2 |
>>> +----+ +-----------+ +----+
>>> (COM1)
>>> RS232/RS485
>>> ^
>>> |
>>> v
>>> Real devices
>>>
>>> V1 and V2 are virtual devices that opens COM7 and COM10 virtual COM
>>> ports. COM7 are virtually connected to COM8, COM10 to COM9 (virtual
>>> null-modem cables performed by com0com software).
>>>
>>> RS232_HUB is a software that opens COM8, COM10 and COM1. It continually
>>> listens to those ports and forward each byte received to other ports.
>>>
>>> Do you know some software that is similat to the idea of RS232 hub?
>>
>> It should be possible to write someting like that in Python using
>> pyserial in less time than it took to draw the ASCII-art picture. :)
>>
>
> If you are able to code in Python :-)
>
The need for this sort of thing is exactly why you need to learn. I
know it's a pain, but it's worth it. Here's something close to right in Tcl:
proc dump { s } {
return ""
// or ...
set ret ""
foreach c [ split $s "" ] {
set ret [ set ret][format "%02x " $c ]
}
return $ret
}
proc rd ( name h } {
if {[eof $h]} {
puts "Failure on $name <$h>"
exit 99
}
set ib [ read $h ]
# eof is valid only after a read ....
if {[eof $h]} { puts "trouble brewing on $name ..." }
puts "read [string length $ib ] bytes on $h [ dump $ib ] "
foreach a $::portz {
if {$a == $name} {
continue
}
puts -nonewline $::portz($a) $ib
# for good measure and great justice
flush $::ports($a)
puts "sent [string length $ib ] bytes on $a [ dump $ib ] "
}
}
set portz { COM8: COM10: COM1: }
foreach a $portz {
set f($a) [ open $a "r+" ]
fconfigure $f($a) -translation binary -blocking 0 -buffering none
fileevent $f($a) readable [ list $a $f($a) ] rd
}
// bow to the event loop
while {1} {
after 500 { set ::tick 1 }
vwait ::tick
# optional...
# puts -nonewline "."
# flush stdout
}
--
Les Cargill
Reply by Grant Edwards●September 9, 20152015-09-09
On 2015-09-09, pozz <pozzugno@gmail.com> wrote:
> Il 09/09/2015 17:20, Grant Edwards ha scritto:
>> On 2015-09-09, pozz <pozzugno@gmail.com> wrote:
>>
>>> Now I'm searching a software running on Windows machine that opens a
>>> number of COM ports and forward every byte received from one port to all
>>> the other ports. In this way I can simulate a multi-drop bus.
>>> It should be a RS232 virtual hub.
>>>
>>> +----+ +-----------+ +----+
>>> | V1 |(COM7)<--->(COM8)| RS232_HUB |(COM9)<--->(COM10)| V2 |
>>> +----+ +-----------+ +----+
>>> (COM1)
>>> RS232/RS485
>>> ^
>>> |
>>> v
>>> Real devices
>>>
>>> V1 and V2 are virtual devices that opens COM7 and COM10 virtual COM
>>> ports. COM7 are virtually connected to COM8, COM10 to COM9 (virtual
>>> null-modem cables performed by com0com software).
>>>
>>> RS232_HUB is a software that opens COM8, COM10 and COM1. It continually
>>> listens to those ports and forward each byte received to other ports.
>>>
>>> Do you know some software that is similat to the idea of RS232 hub?
>>
>> It should be possible to write someting like that in Python using
>> pyserial in less time than it took to draw the ASCII-art picture. :)
>>
>
> If you are able to code in Python :-)
Everyone is able to code in Python -- some people just don't know it yet. ;)
--
Grant Edwards grant.b.edwards Yow! My NOSE is NUMB!
at
gmail.com
Reply by pozz●September 9, 20152015-09-09
Il 09/09/2015 17:20, Grant Edwards ha scritto:
> On 2015-09-09, pozz <pozzugno@gmail.com> wrote:
>
>> Now I'm searching a software running on Windows machine that opens a
>> number of COM ports and forward every byte received from one port to all
>> the other ports. In this way I can simulate a multi-drop bus.
>> It should be a RS232 virtual hub.
>>
>> +----+ +-----------+ +----+
>> | V1 |(COM7)<--->(COM8)| RS232_HUB |(COM9)<--->(COM10)| V2 |
>> +----+ +-----------+ +----+
>> (COM1)
>> RS232/RS485
>> ^
>> |
>> v
>> Real devices
>>
>> V1 and V2 are virtual devices that opens COM7 and COM10 virtual COM
>> ports. COM7 are virtually connected to COM8, COM10 to COM9 (virtual
>> null-modem cables performed by com0com software).
>>
>> RS232_HUB is a software that opens COM8, COM10 and COM1. It continually
>> listens to those ports and forward each byte received to other ports.
>>
>> Do you know some software that is similat to the idea of RS232 hub?
>
> It should be possible to write someting like that in Python using
> pyserial in less time than it took to draw the ASCII-art picture. :)
>
If you are able to code in Python :-)
Reply by Grant Edwards●September 9, 20152015-09-09
On 2015-09-09, pozz <pozzugno@gmail.com> wrote:
> Now I'm searching a software running on Windows machine that opens a
> number of COM ports and forward every byte received from one port to all
> the other ports. In this way I can simulate a multi-drop bus.
> It should be a RS232 virtual hub.
>
> +----+ +-----------+ +----+
>| V1 |(COM7)<--->(COM8)| RS232_HUB |(COM9)<--->(COM10)| V2 |
> +----+ +-----------+ +----+
> (COM1)
> RS232/RS485
> ^
> |
> v
> Real devices
>
> V1 and V2 are virtual devices that opens COM7 and COM10 virtual COM
> ports. COM7 are virtually connected to COM8, COM10 to COM9 (virtual
> null-modem cables performed by com0com software).
>
> RS232_HUB is a software that opens COM8, COM10 and COM1. It continually
> listens to those ports and forward each byte received to other ports.
>
> Do you know some software that is similat to the idea of RS232 hub?
It should be possible to write someting like that in Python using
pyserial in less time than it took to draw the ASCII-art picture. :)
--
Grant Edwards grant.b.edwards Yow! Are we wet yet?
at
gmail.com
Reply by pozz●September 9, 20152015-09-09
I often work on small electronic devices that communicates over a
multi-drop half-duplex two-wires RS485 network.
I usually try to compile all the projects for the developing Windows
machine (I use mingw as the compiler). Simulating and mimic the hardware
in some way.
The best simulation for the RS485 is a typical RS232 port with a
RS232-RS485 attached (actually it is a very cheap USB-RS485 that is seen
as a virtual COM port by Windows).
In this way, I can debug a device very fast on the developing Windows
machine. The "virtual" device communicates with real devices on the bus.
Now I'd like to have two (or more) virtual devices running on the
developing machine. Of course, they should communicate with each other
*and* with real devices connected to the RS232-RS485 converter.
The idea is to use one *pair* virtual COM ports
(com0com.sourceforge.net) for each virtual device *and* a real COM port
for the real devices.
Now I'm searching a software running on Windows machine that opens a
number of COM ports and forward every byte received from one port to all
the other ports. In this way I can simulate a multi-drop bus.
It should be a RS232 virtual hub.
+----+ +-----------+ +----+
| V1 |(COM7)<--->(COM8)| RS232_HUB |(COM9)<--->(COM10)| V2 |
+----+ +-----------+ +----+
(COM1)
RS232/RS485
^
|
v
Real devices
V1 and V2 are virtual devices that opens COM7 and COM10 virtual COM
ports. COM7 are virtually connected to COM8, COM10 to COM9 (virtual
null-modem cables performed by com0com software).
RS232_HUB is a software that opens COM8, COM10 and COM1. It continually
listens to those ports and forward each byte received to other ports.
Do you know some software that is similat to the idea of RS232 hub?