FTDI F4232 in RS485 and vedirect mode

So we recently need more than one vedirect and also rs485 and maybe rs232 , as i am hobby hacker i had a few boards with rs485 using a mcu for cts/dsr control so only tx/rx. I also had some mppt controllers to also connect to a victron multiplus gx so i took a leaf out off grid garage and got a 4 port galv isolated ftdi device and while it worked for ve.direct it did not for other types so i came up with a script that adds rs485 devices as first detect then other types.

uart_patch.sh :-

#start of copy paste

#This script will check the serial-start rules for the patch first before attempting to add it, if found it will exit
searchString=“#Support FT4232 for both RS485 and ve.direct”
file=“/etc/udev/rules.d/serial-starter.rules”
if grep -Fxq “$searchString” $file
then
echo “Patch already in $file”
else
echo “Adding patch to $file” && /opt/victronenergy/swupdate-scripts/remount-rw.sh && sed -i ‘s/# The VE USB RS485 has a FT232R, but that chip can also rs232 etc, so also check default/#Support FT4232 for both RS485 and ve.direct\nACTION==“add”, ENV{ID_BUS}==“usb”, ENV{ID_MODEL}==“Quad_RS232-HS”, ENV{VE_SERVICE}=“cgwacs:default”\n# The VE USB RS485 has a FT232R, but that chip can also rs232 etc, so also check default/’ /etc/udev/rules.d/serial-starter.rules && mount -o remount,ro /dev/mmcblk1p2
fi

#end of uart patch paste

/data/rc.local:-

#start of copy/paste
#start the patch check each boot
/data/uart_patch.sh

#end of rc.local past

this allows you to use cheap 4 port usb to tll and then add on cheap rs485/rs232 ports onto those boards