V2.Variable data type specified when you first use it (and optionally - in the future), and is separated from the name of the point. V2.1 : manage programs that are making too much errors on transmitting (rate : 10 errors/mn) **Happy new year to all enjoyed guys which are working on programing nice applications with Velbus and (of course) to all Velbus employees who works hard to help us ** Could be launch with parameter (possible to create a shortcut in start menu).Multiples Ethernet clients are supported (they all receive frame from Velbus bus but from other clients too).Each messages from Ethernet are checked (lengh, checksum, …).PB_Velbus-server manage speed (each message from Ethernet to Velbus are delayed to avoid full buffer or bus down).Velbus/PB_Velbus-server.exeĪnd here, is a picture on how it works : PB_Velbus-server COMx YYYY (where x is a valid COM port on PC and YYYY is an ethernet port number)īelow, you can see an example with : PB_Velbus-server COM4 8080Īnd for all coders, here is the source code : If something doesn’t check out, we discard the first byte and keep on going Continue doing the above until we no longer have 4 bytes in the buffer (= nothing useable until the next read).Check if the checksum is correct and the packet ends with ETX.Wait until I have 4 bytes + number of databytes + 2 (checksum and ETX) = the entire packet.Perform some checks on the 4 bytes that I already have.Wait until I have 4 bytes in the buffer (so we have all header bytes, including the byte that tells us the number of data bytes).When parsing you should check if you really have a packet: That is a requirement for HomeCenter I will remove this in the next version for the ‘Network connection’ option since it is not strictly needed there ProcedureReturn Somme Return the checksum value Somme = Somme + 1 (AND operation) and inverse with XOR (!), them add ‘1’ Somme = (Somme & $FF) ! $FF As PureBasic use signed integer, need to remove higher value Somme=Somme+PeekB(*B+tr) & $FF Adding each byte from the packet Messages()\Cmd = AllocateMemory(messages()\len)ĬopyMemory(*bus+t,messages()\cmd,messages()\len)įor tr=0 To longueur Loop from 0 to checksum byte -1 If PeekB(*bus+fintrame) = $04 And (PeekB(*bus+crcloc) & $FF)=crc PrintN(“Error : Can’t create the server (port in use ?).”) RXLen = ReadSerialPortData(0,*BSin,Serial)Įrr = SendNetworkData(Client(), *BSin, RXLen) PrintN("Closing Connexion ID "+Str(ClientID)+" (Client Number : "+Str(ListSize(Client()))+")") PrintN("NET -> VelBUS : "+Str(N)+" messages received ("+Str(RXLen)+" bytes received)") RXLen = ReceiveNetworkData(ClientID, *BNin, 4096) If ListSize(messages()) And ElapsedMilliseconds()-d > 40Įrr = WriteSerialPortData(0, messages()\cmd, messages()\len) PrintN(FormatDate("%dd/%mm%/%yyyy %hh:%ii:%ss",Date()))ĮndIf Send bufferised messages with 60ms delay server is alive : show date (french format) ![]() PrintN(" ] Listening on Ethernet port : "+Str(port)) PrintN(“Error : Can’t initialize the network !”) PrintN(“PB_Velbus-Server v2.0 : open port “+port$+” done”) ![]() If ProgramParameter(1) : port = Val(ProgramParameter(1)) : EndIf If ProgramParameter(0) : port$ = ProgramParameter(0) : EndIf PrintN(“PB_Velbus-server.exe default = COM”) PrintN(“PB_Velbus-server.exe SERIALport NETWORKport (ex: PB_Velbus-server.exe COM4 8131)”) If FindString(UCase(ProgramParameter(0)),“H”,1) Or FindString(UCase(ProgramParameter(0)),"?",1) if parameter are transmit after commandline v2 -> try to delay message from Ethernet -> Velbus This frame is received at VelbusLink startup : it probably mean “VelbusLink 7” (even if I’ve loose de ‘V’)īut now, here is the PureBasic Velbus-Server Working hard on a Purebasic Velbus server and trying VelbusLink through it… and do you know ? I’ve see a frame like this : 65 6c 62 75 73 4c 69 6e 6b 20 38 2e 34 2e. PrintN("Error : Can't create the server (port in use ?).")īus OFF and Buffer FULL not managed for now but hey… it midnight, I’ve to sleep PrintN("Closing Connexion ID "+Str(Client())+" (Client Number : "+Str(ListSize(Client()))+")")Įrr = SendNetworkData(ClientID, *BSin, RXLen) ![]() Each Client but ClientID receive frame transmit by ClientIDĮrr = SendNetworkData(Client(), *BNin, RXLen) RXLen = ReceiveNetworkData(ClientID, *BNin, 1024)Įrr = WriteSerialPortData(0, *BNin, RXLen) PrintN("Opening Connexion ID "+Str(Client())+" for "+ip$+" (Client Number : "+Str(ListSize(Client()))+")") PrintN("Listening on Ethernet port : "+Str(port)) PrintN("Error : Can't initialize the network !") If OpenSerialPort(0, Port$, 9600, #PB_SerialPort_NoParity, 8, 1, #PB_SerialPort_NoHandshake, 2048, 2048) Velbus server 1.0 by Golfy (Purebasic 4.60)ĬompilerIf #PB_Compiler_OS = #PB_OS_Windows You can try this source code : it’s Purebasic code but there is a free version of Purebasic (so you can modify and compile your own code)
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |