Skip to content

Commit

Permalink
hotfix string attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
FerroO2000 committed Sep 12, 2023
1 parent 4cf7407 commit b3e171b
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 9 deletions.
22 changes: 17 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
// Package main
package main

import (
"github.com/squadracorsepolito/jsondbc/pkg/cangoru"
)
import "github.com/squadracorsepolito/jsondbc/cmd"

func main() {
//cmd.Execute()
if err := cangoru.ReadFromDBC("examples/multiplexed_signal.dbc"); err != nil {
cmd.Execute()
/*can, err := cangoru.NewCANFromDBC("examples/simple.dbc")
if err != nil {
panic(err)
}
if err := can.ToDBC("res_simple.dbc"); err != nil {
panic(err)
}
can, err = cangoru.NewCANFromDBC("examples/multiplexed_signal.dbc")
if err != nil {
panic(err)
}
if err := can.ToDBC("res_multiplexed_signal.dbc"); err != nil {
panic(err)
}*/
}
4 changes: 3 additions & 1 deletion pkg/dbc_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,10 @@ func (w *DBCWriter) writeBusSpeed(f *file, speed uint32) {
strSpeed := ""
if speed > 0 {
strSpeed = formatUint(speed)
f.print(sym.DBCBusSpeed, ":", strSpeed, ":", strSpeed, ",", strSpeed)
} else {
f.print(sym.DBCBusSpeed, ":")
}
f.print(sym.DBCBusSpeed, ":", strSpeed, ":", strSpeed, ",", strSpeed)
f.print()
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ func (m *Message) validate() error {
if m.Length == 0 {
return fmt.Errorf("message [%s] length cannot be 0", m.messageName)
}
if len(m.childSignals) == 0 {
/*if len(m.childSignals) == 0 {
return fmt.Errorf("message [%s] has no signals", m.messageName)
}
}*/

for _, sig := range m.childSignals {
if err := sig.validate(); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/reg/dbc.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var (
DBCMessageComment = regexp.MustCompile(`^(?:CM_) *(?:BO_) *(?P<msg_id>\d+) *"(?P<desc>.*)" *;$`)
DBCSignalComment = regexp.MustCompile(`^(?:CM_) *(?:SG_) *(?P<msg_id>\d+) *(?P<sig_name>\w+) *"(?P<desc>.*)" *;$`)

DBCAttribute = regexp.MustCompile(`^(?:BA_DEF_) *(?P<att_kind>SG_|BU_|BO_)? *"(?P<att_name>\w+)" *(?P<att_type>INT|FLOAT|STRING|ENUM) *(?P<att_data>.*[^;]) *;`)
DBCAttribute = regexp.MustCompile(`^(?:BA_DEF_) *(?P<att_kind>SG_|BU_|BO_)? *"(?P<att_name>\w+)" *(?P<att_type>INT|FLOAT|STRING|ENUM)(?:;| *(?P<att_data>.*[^;]) *;)`)

DBCAttributeDefault = regexp.MustCompile(`^(?:BA_DEF_DEF_) *"(?P<att_name>\w+)" *(?P<att_data>.*[^;]) *;`)

Expand Down

0 comments on commit b3e171b

Please sign in to comment.