SERAD MCS 32 EX Guide D'utilisation page 140

Table des Matières

Publicité

Documentation MCS32
' * INITIALISATION *
' *
'
' ATTENTION!!! =>Déclarer en variable globale sauvegardée:
' TableModbus
'
NumeroMcs#=1 'numéro de la mcs32
TimeOut&=10
'
AdresseModBus%=600
NombreModbus%=300
' init compteurs de maintenance
CmtMessage&=0
ErrLiaison&=0
ErrAdresse&=0
ErrData&=0
'ouverture serial2
Open "Serial2:9600,8,N,1" As #2
Clearin #2 'vide buffer rxd
TempoRxd&=Time
'------------------------------------------------------------
' *
' * RECEPTION *
' *
InitRxd:
PtrRxd#=0
Rxd$=""
'
WaitRxd:
If Carin(#2)<>0 Then Jump ReadRxd
If PtrRxd#=0 Then Goto WaitRxd
If Time>TempoRxd& Then Goto InitRxd
Goto WaitRxd
'
ReadRxd:
TempoRxd&=Time+TimeOut&
If PtrRxd#>=2 Then Jump MessageRxd
If PtrRxd#=1 Then Jump Car2Rxd
Car1Rxd:
CarRxd$=Input$ #2,1
Car1tRxd:
NumMcs#=Asc(CarRxd$)
If (NumMcs#<>NumeroMcs#) And (NumMcs#<>0) Then Jump InitRxd
PtrRxd#=1
Rxd$=CarRxd$
Jump WaitRxd
Car2Rxd:
CarRxd$=Input$ #2,1
NumFonction#=Asc(CarRxd$)
If (NumFonction#<>3) And (NumFonction#<>4) And (NumFonction#<>16) Then Jump
Car1tRxd
PtrRxd#=2
Rxd$=Rxd$+CarRxd$
Jump WaitRxd
MessageRxd:
CarRxd$=Input$ #2,Carin(#2)
PtrRxd#=PtrRxd#+len(CarRxd$)
If PtrRxd#>240 Then Jump InitRxd
Rxd$=Rxd$+CarRxd$
If NumFonction#=16 Then
If PtrRxd#<7 Then Jump WaitRxd
If PtrRxd#<(Asc(Rxd$,7)+9) Then Jump WaitRxd
Rxd$=Left$(Rxd$,Asc(Rxd$,7)+9)
Else
If PtrRxd#<8 Then Jump WaitRxd
Rxd$=Left$(Rxd$,8)
End If
'
R342
EX
type:entier
nombre:255
'10ms délai maxi entre 2 caractères recus
'Adresse de début de la table
'Nombre de mots dans la table
- 140 -
SERAD S.A.

Publicité

Table des Matières
loading

Table des Matières