<switch expr="$ jumpproto ">
<c a s e value="1">
<nextproto proto="#T123"/>
</ c a s e>
<default>
<switch expr="$ l i n k l a y e r ">
<c a s e value="2">
<nextproto proto="#ESWP_CAN"/>
</ c a s e>
<default>
<nextproto proto="#can "/>
</ default>
</ switch>
</ default>
</ switch>
</ e n c a p s u l a t i o n>
</ p r o t o c o l>
<p r o t o c o l name=" can " longname=" C o n t r o l l e r Area Network" comment="
Parses the CAN p r o t o c o l as b a s i c a l l y d e f i n e d without i n t e r p r e t a t i o n o f i d e n t i f i e r ">
<execute−code>
<a f t e r>
<assign−v a r i a b l e name="$ c a n I d e n t i f i e r " value=" b u f 2 i n t ( i d e n t i f i e r )
"/>
</ a f t e r>
</ execute−code>
<format>
< f i e l d s>
< f i e l d name=" i d e n t i f i e r " longname=" I d e n t i f i e r " type=" f i x e d " s i z e=
"4" showtemplate=" FieldDec ">
< f i e l d name=" tog " longname=" Toggle " type=" b i t " mask="0 x0000400 "
s i z e="4" showtemplate=" FieldDec "/>
< f i e l d name=" s r c " longname=" Source " type=" b i t " mask="0x00003E0"
s i z e="4" showtemplate=" FieldDec "/>
< f i e l d name=" d e s t " longname=" D e s t i n a t i o n " type=" b i t " mask="0 x000001F" s i z e="4" showtemplate=" FieldDec "/>
</ f i e l d>
< f i e l d type=" b i t " name=" f l e n g t h " longname="Frame l e n g t h " mask="0 x001E" s i z e="2" showtemplate=" FieldDec " />
< f i e l d type=" b i t " name=" f l a g s " longname=" Flags " mask="0xFFE0"
s i z e="2" showtemplate=" FieldBin ">
< f i e l d name="swOverrun" longname=" Software overrun " type=" b i t "
mask="0 x8000 " s i z e="2" showtemplate=" FieldDec "/>
< f i e l d name="hwOverrun" longname="Hardware overrun " type=" b i t "
mask="0 x4000 " s i z e="2" showtemplate=" FieldDec "/>
< f i e l d name=" txrq " longname="TX REQ" type=" b i t " mask="0 x1000 "
s i z e="2" showtemplate=" FieldDec "/>
< f i e l d name=" txack " longname="TX ACK" type=" b i t " mask="0 x0800 "
s i z e="2" showtemplate=" FieldDec "/>
< f i e l d name=" n e r r " longname="NERR" type=" b i t " mask="0 x0200 "
s i z e="2" showtemplate=" FieldDec "/>
< f i e l d name=" errFrame " longname=" Error frame " type=" b i t " mask="
0 x0400 " s i z e="2" showtemplate=" FieldDec "/>
< f i e l d name="wakeup" longname="Wakeup message " type=" b i t " mask=
"0 x0100 " s i z e="2" showtemplate=" FieldDec "/>
< f i e l d name=" ext " longname="Extended CAN" type=" b i t " mask="0 x0080 " s i z e="2" showtemplate=" FieldDec "/>
< f i e l d name=" std " longname=" Standard CAN" type=" b i t " mask="0 x0040 " s i z e="2" showtemplate=" FieldDec "/>
C.3. FOSS' CAN PROTOKOL 113
< f i e l d name=" r t r " longname="Remote r e q u e s t " type=" b i t " mask="0 x0020 " s i z e="2" showtemplate=" FieldDec "/>
</ f i e l d>
< f i e l d name=" r e s " longname=" Reserved " type=" f i x e d " s i z e="1"
showtemplate=" FieldHide "/>
< f i e l d name=" l e n g t h " longname="Data l e n g t h " type=" b i t " s i z e="1"
mask="0x70" showtemplate=" FieldDec "/>
< f i e l d name=" type " longname=" Message type " type=" b i t " s i z e="1"
mask="0x0F" showtemplate=" FieldType "/>
</ f i e l d s>
</ format>
<e n c a p s u l a t i o n>
<nextproto proto="#d e f a u l t p r o t o "/>
</ e n c a p s u l a t i o n>
<!−− Workaround f o r bug in Netbee . The summary i s not used , but t h i s i s p o o r l y handled by Netbee −−>
<v i s u a l i z a t i o n>
<showsumtemplate name=" whatever " />
</ v i s u a l i z a t i o n>
</ p r o t o c o l>
<p r o t o c o l name="ESWP_CAN" longname="ESWP CAN" comment=" Parses the CAN p r o t o c o l as b a s i c a l l y d e f i n e d with i n t e r p r e t a t i o n o f
i d e n t i f i e r ">
<execute−code>
<a f t e r>
<assi gn−v a r i a b l e name="$ c a n I d e n t i f i e r " value=" b u f 2 i n t ( i d e n t i f i e r )
"/>
</ a f t e r>
</ execute−code>
<format>
< f i e l d s>
< f i e l d name=" i d e n t i f i e r " longname=" I d e n t i f i e r " type=" f i x e d " s i z e=
"4" showtemplate=" FieldDec ">
< f i e l d name=" tog " longname=" Toggle " type=" b i t " mask="0 x0000400 "
s i z e="4" showtemplate=" FieldDec "/>
< f i e l d name=" s r c " longname=" Source " type=" b i t " mask="0x00003E0"
s i z e="4" showtemplate=" FieldDec "/>
< f i e l d name=" d e s t " longname=" D e s t i n a t i o n " type=" b i t " mask="0 x000001F" s i z e="4" showtemplate=" FieldDec "/>
</ f i e l d>
< f i e l d type=" b i t " name=" f l e n g t h " longname="Frame l e n g t h " mask="0 x001E" s i z e="2" showtemplate=" FieldDec " />
< f i e l d type=" b i t " name=" f l a g s " longname=" Flags " mask="0xFFE0"
s i z e="2" showtemplate=" FieldBin ">
< f i e l d name="swOverrun" longname=" Software overrun " type=" b i t "
mask="0 x8000 " s i z e="2" showtemplate=" FieldDec "/>
< f i e l d name="hwOverrun" longname="Hardware overrun " type=" b i t "
mask="0 x4000 " s i z e="2" showtemplate=" FieldDec "/>
< f i e l d name=" txrq " longname="TX REQ" type=" b i t " mask="0 x1000 "
s i z e="2" showtemplate=" FieldDec "/>
< f i e l d name=" txack " longname="TX ACK" type=" b i t " mask="0 x0800 "
s i z e="2" showtemplate=" FieldDec "/>
< f i e l d name=" n e r r " longname="NERR" type=" b i t " mask="0 x0200 "
s i z e="2" showtemplate=" FieldDec "/>
< f i e l d name=" errFrame " longname=" Error frame " type=" b i t " mask="
0 x0400 " s i z e="2" showtemplate=" FieldDec "/>
< f i e l d name="wakeup" longname="Wakeup message " type=" b i t " mask=
"0 x0100 " s i z e="2" showtemplate=" FieldDec "/>
< f i e l d name=" ext " longname="Extended CAN" type=" b i t " mask="0 x0080 " s i z e="2" showtemplate=" FieldDec "/>
< f i e l d name=" std " longname=" Standard CAN" type=" b i t " mask="0 x0040 " s i z e="2" showtemplate=" FieldDec "/>
< f i e l d name=" r t r " longname="Remote r e q u e s t " type=" b i t " mask="0 x0020 " s i z e="2" showtemplate=" FieldDec "/>
</ f i e l d>
< f i e l d name=" r e s " longname=" Reserved " type=" f i x e d " s i z e="1"
showtemplate=" FieldHide "/>
< f i e l d name=" l e n g t h " longname="Data l e n g t h " type=" b i t " s i z e="1"
mask="0x70" showtemplate=" FieldDec "/>
< f i e l d name=" type " longname=" Message type " type=" b i t " s i z e="1"
mask="0x0F" showtemplate=" FieldType "/>
<!−−< f i e l d name="pad" longname="Padding " type=" padding " s i z e="1"
showtemplate=" Hide "/>−−>
</ f i e l d s>
</ format>
<e n c a p s u l a t i o n>
<switch expr=" b u f 2 i n t ( type ) ">
<c a s e value="2">
<nextproto proto="#m u l t i s s " />
</ c a s e>
<default>
<nextproto proto="#d e f a u l t p r o t o "/>
</ default>
</ switch>
</ e n c a p s u l a t i o n>
<!−− Workaround f o r bug in Netbee . The summary i s not used , but t h i s i s p o o r l y handled by Netbee −−>
<v i s u a l i z a t i o n>
<showsumtemplate name=" whatever " />
<showtemplate name=" FieldType " showtype="hex">
<showmap>
<switch expr=" b u f 2 i n t ( t h i s ) ">
<c a s e value="0" show=" Reserved "/>
<c a s e value="1" show=" S i n g l e "/>
<c a s e value="2" show=" M u l t i s s "/>
<c a s e value="3" show="Segment"/>
<c a s e value="4" show=" Reserved "/>
<c a s e value="5" show=" Reserved "/>
<c a s e value="6" show=" Reserved "/>
<c a s e value="7" show=" Reserved "/>
<c a s e value="8" show=" Linkupr "/>
<c a s e value="9" show=" Linkupa "/>
<c a s e value="10" show="Ready"/>
<c a s e value="11" show="Flow s t a r t "/>
<c a s e value="12" show="Flow stop "/>
<c a s e value="13" show=" Reserved "/>
<c a s e value="14" show=" Reserved "/>
<c a s e value="15" show=" Reserved "/>
</ switch>
</showmap>
</ showtemplate>
</ v i s u a l i z a t i o n>
</ p r o t o c o l>
<p r o t o c o l name=" m u l t i s s " longname=" Multi segment ">
<format>
< f i e l d s>
C.3. FOSS' CAN PROTOKOL 115
< f i e l d name=" l e n g t h " longname=" Length " type=" f i x e d " s i z e="2"
showtemplate=" FieldDec " bigendian=" yes "/>
< f i e l d name=" s r c " longname=" Source " type=" f i x e d " s i z e="2"
showtemplate=" FieldHex " bigendian=" yes "/>
< f i e l d name=" d e s t " longname=" D e s t i n a t i o n " type=" f i x e d " s i z e="2"
showtemplate=" FieldHex " bigendian=" yes "/>
</ f i e l d s>
</ format>
</ p r o t o c o l>
<p r o t o c o l name="T123" longname="T123">
<format>
< f i e l d s>
< f i e l d name=" s r c " longname=" Source " type=" f i x e d " s i z e="2"
showtemplate=" FieldHex "/>
< f i e l d name=" d e s t " longname=" D e s t i n a t i o n " type=" f i x e d " s i z e="2"
showtemplate=" FieldHex "/>
< f i e l d name=" r e p l y i d " longname=" Reply ID" type=" f i x e d " s i z e="1"
showtemplate=" FieldHex "/>
< f i e l d name=" t1 " longname="T1" type=" f i x e d " s i z e="2" showtemplate
=" FieldHex "/>
< f i e l d name=" t2 " longname="T2" type=" f i x e d " s i z e="1" showtemplate
=" FieldHex "/>
< f i e l d name=" t3 " longname="T3" type=" f i x e d " s i z e="1" showtemplate
=" FieldHex "/>
</ f i e l d s>
</ format>
</ p r o t o c o l>
<p r o t o c o l name=" d e f a u l t p r o t o " longname=" Payload ">
<format>
< f i e l d s>
< f i e l d type=" v a r i a b l e " name=" payload " longname="Data payload "
expr="$ p a c k e t l e n g t h − $ c u r r e n t o f f s e t " showtemplate="
Field4BytesHex "/>
</ f i e l d s>
</ format>
</ p r o t o c o l>
<v i s u a l i z a t i o n>
<!−− Workaround f o r bug in Netbee . The summary i s not used , but t h i s i s p o o r l y handled by Netbee −−>
<showsumstruct>
<sumsection name=" whatever "/>
</ showsumstruct>
<showtemplate name=" Field4BytesHex " showtype="hex" showgrp="4"
showsep=" "/>
<showtemplate name=" FieldBin " showtype=" bin "/>
<showtemplate name=" FieldDec " showtype=" dec "/>
<showtemplate name=" FieldHex " showtype="hex"/>
<showtemplate name=" FieldHide " showtype=" hide "/>
</ v i s u a l i z a t i o n>
</ netpdl>
Appendix D
NetPDL problemer
I dette afsnit præsenteres nogle af de problemer, der er opstået i projektet på baggrund af brugen af NetBee biblioteket. Det præsenteres ligeledes, hvilke work-arounds, der kan laves for at løse problemet.
D.1 Problemer ved denition af felt
• Fejl værdi i type attributten i et felt giver udeneret fejl. Så tjek denne attribut nøje!
• Man kan ikke have et bit felt med nestede felter og så et bit felt bagefter.
Men det virker, hvis det andet bitfelt skrives først i stedet, fx virker dette ikke:
< f i e l d type=" b i t " name=" f l a g s " longname=" Flags " mask="0xFFE0"
s i z e="2">
< f i e l d name=" n e s t " longname=" Nested f i e l d " type=" b i t " mask="0 x0020 " s i z e="2"/>
</ f i e l d>
< f i e l d type=" b i t " name=" l e n g t h " longname=" Length " mask="0x001E"
s i z e="2" />
Men dette gør:
< f i e l d type=" b i t " name=" l e n g t h " longname=" Length " mask="0x001E"
s i z e="2" />
< f i e l d type=" b i t " name=" f l a g s " longname=" Flags " mask="0xFFE0"
s i z e="2">
< f i e l d name=" n e s t " longname=" Nested f i e l d " type=" b i t " mask="0 x0020 " s i z e="2"/>
</ f i e l d>
Eneste forskel er rækkefølgen, felterne sendes til frameworket i, dvs. de vil optræde i samme rækkefølge der.
• Der er problemer med håndteringen af bit felter. Betragt følgende 117
< f i e l d type=" b i t " name=" f l a g s " longname=" Flags " mask="0x01FF"
s i z e="2">
< f i e l d name=" n e s t " longname=" Nested f i e l d " type=" b i t " mask="0 x0001 " s i z e="2"/>
</ f i e l d>
< f i e l d name=" another " longname=" Another f i e l d " type=" b i t " mask="
0xDD" s i z e="1"/>
Feltet, another, virker ikke. Det kan løses ved at enten droppe indlejringen af felter eller ved at indsætte et pseudo-felt.
< f i e l d type=" b i t " name=" f l a g s " longname=" Flags " mask="0x01FF"
s i z e="2">
< f i e l d name=" n e s t " longname=" Nested f i e l d " type=" b i t " mask="0 x0001 " s i z e="2"/>
</ f i e l d>
< f i e l d name=" pseudo " longname="Pseudo f i e l d " type=" f i x e d " s i z e="
1" showtemplate=" FieldHide "/>
< f i e l d name=" another " longname=" Another f i e l d " type=" b i t " mask="
0xDD" s i z e="1"/>
Den løsning kræver selvfølgelig, at man kan få byte strømmen til at overholde dette format (altså indsætte en tom byte, der ikke benyttes eller vises.
• Fejl i BigEndian håndtering i sammenhæng med decimal visning. Følgende vises forkert:
< f i e l d type=" f i x e d " name=" t1 " longname="T1" s i z e="2" bigendian="
yes " showtemplate=" FieldDec "/>
<v i s u a l i z a t i o n>
<showtemplate name=" FieldDec " showtype=" dec "/>
</ v i s u a l i z a t i o n>
Den ene af de to bytes i T1 feltet benyttes ikke i visningen, dvs. fx bliver 0xEEFF til 0xEE00. Begge nedenstående eksempler er dog korrekte:
< f i e l d type=" f i x e d " name=" t1 " longname="T1" s i z e="2"
showtemplate=" FieldDec "/>
<v i s u a l i z a t i o n>
<showtemplate name=" FieldDec " showtype=" dec "/>
</ v i s u a l i z a t i o n>
< f i e l d type=" f i x e d " name=" t1 " longname="T1" s i z e="2" bigendian="
yes " showtemplate=" FieldHex "/>
<v i s u a l i z a t i o n>
<showtemplate name=" FieldHex " showtype="hex"/>
</ v i s u a l i z a t i o n>
Der er ikke en god work-around til problemet udover at undgå kombina-tionen af decimal visning og big-endian format.
• Der er generelt forvirring omkring big-endian og little-endian. Sættes attri-butten, bigendian i <Field> til yes, får man en little-endian fortolkning, mens en no værdi giver en big-endian fortolkning. Dette er meget forvir-rende!