Skip to content

Commit

Permalink
Merge pull request #44 from UlfBj/v3.0
Browse files Browse the repository at this point in the history
VISSv3.0 start of development
  • Loading branch information
UlfBj authored Oct 14, 2024
2 parents 12de8c2 + c298b3f commit e093d6b
Show file tree
Hide file tree
Showing 17 changed files with 1,142 additions and 139 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ Ulf Björkengren - Ford Motor Company
Peter Winzell - Volvo Cars

# COVESA VISS Reference Implementation - VISSR
This project implements the COVESA VISS v2 specification under development at [https://github.com/COVESA/vehicle-information-service-specification](https://github.com/COVESA/vehicle-information-service-specification).
This project provides a reference implementation of the released [COVESA VISSv2.0 specification](https://github.com/COVESA/vehicle-information-service-specification/releases/tag/v2.0) on the v2.0 branch,
and an ongoing development of a reference implementation of the [VISSv3.0 specification](https://github.com/COVESA/vehicle-information-service-specification) on the master branch.

# Tutorial
A tutorial can be found <a href="https://covesa.github.io/vissr/">here</a>.
Expand Down
3 changes: 3 additions & 0 deletions client/client-1.0/Javascript/appclient_commands.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
Get request:
{"action":"get","path":"Vehicle/Cabin/Door/Row1/DriverSide/IsOpen","requestId":"232"}
{"action":"get","path":"Vehicle.Acceleration.Longitudinal","requestId":"233"}
{"action":"get","path":"Server.Support.Protocol","requestId":"133"}
{"action":"get","path":"Vehicle.Chassis.AxleCount","requestId":"321"}


Get request for historic data:
{"action":"get","path":"Vehicle.Acceleration.Longitudinal","filter":{"type":"history","parameter":"P2DT12H"},"requestId":"234"}
Expand Down
22 changes: 20 additions & 2 deletions feeder/feeder-template/feederv3/feederv3.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,14 +233,18 @@ func statestorageSet(path string, val string, ts string) int {

func udsReader(conn net.Conn, inputChan chan DomainData, udsChan chan string) {
defer conn.Close()
buf := make([]byte, 512)
buf := make([]byte, 8192)
for {
n, err := conn.Read(buf)
if err != nil {
utils.Error.Printf("udsReader:Read failed, err = %s", err)
continue
}
utils.Info.Printf("udsReader:Server message: %s", string(buf[:n]))
// utils.Info.Printf("udsReader:Server message: %s", string(buf[:n]))
if n > 8192 {
utils.Error.Printf("udsReader:Max message size of 8192 chars exceeded. Message dropped")
continue
}
var serverMessageMap map[string]interface{}
err = json.Unmarshal(buf[:n], &serverMessageMap)
if err != nil {
Expand Down Expand Up @@ -268,6 +272,20 @@ func udsReader(conn net.Conn, inputChan chan DomainData, udsChan chan string) {
notificationList = slices.Delete(notificationList, i, i+1)
}
}
case "update":
defaultArray := serverMessageMap["defaultList"].([]interface{})
var domainData DomainData
for i := 0; i < len(defaultArray); i++ {
for k, v := range defaultArray[i].(map[string]interface{}) {
// utils.Info.Printf("%d: key=%s, value=%s", i, k, v.(string))
if k == "path" {
domainData.Name = v.(string)
} else if k == "default" {
domainData.Value = v.(string)
}
}
statestorageSet(domainData.Name, domainData.Value, utils.GetRfcTime())
}
default:
utils.Error.Printf("udsReader:Message action unknown = %s", serverMessageMap["action"].(string))
}
Expand Down
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ module github.com/covesa/vissr

go 1.22.1

//replace github.com/COVESA/vss-tools/binary/go_parser/datamodel => /home/ubjorken/Proj/covesa/vss-tools/binary/go_parser/datamodel
//replace github.com/COVESA/vss-tools/binary/go_parser/parserlib => /home/ubjorken/Proj/covesa/vss-tools/binary/go_parser/parserlib

require (
github.com/COVESA/vss-tools/binary/go_parser/datamodel v0.0.0-20240827143318-9495c70b56c2
github.com/COVESA/vss-tools/binary/go_parser/parserlib v0.0.0-20240827143318-9495c70b56c2
Expand Down
17 changes: 8 additions & 9 deletions server/vissv2server/atServer/atServer.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,12 @@ import (
"strings"
"time"

gomodel "github.com/COVESA/vss-tools/binary/go_parser/datamodel"
golib "github.com/COVESA/vss-tools/binary/go_parser/parserlib"
// gomodel "github.com/COVESA/vss-tools/binary/go_parser/datamodel"
// golib "github.com/COVESA/vss-tools/binary/go_parser/parserlib"
"github.com/covesa/vissr/utils"
"github.com/google/uuid"
)

var VSSTreeRoot *gomodel.Node_t

// set to MAXFOUNDNODES in cparserlib.h
const MAXFOUNDNODES = 1500

Expand Down Expand Up @@ -349,10 +347,11 @@ func validateRequestAccess(purpose string, action string, paths []string) int {
numOfPaths := len(paths)
var pathSubList []string
for i := 0; i < numOfPaths; i++ {
var searchData []golib.SearchData_t
var searchData []utils.SearchData_t
numOfWildcardPaths := 1
if strings.Contains(paths[i], "*") {
searchData, numOfWildcardPaths = golib.VSSsearchNodes(paths[i], VSSTreeRoot, MAXFOUNDNODES, true, true, 0, nil, nil)
VSSTreeRoot := utils.SetRootNodePointer(paths[i])
searchData, numOfWildcardPaths = utils.VSSsearchNodes(paths[i], VSSTreeRoot, MAXFOUNDNODES, true, true, 0, nil, nil)
pathSubList = make([]string, numOfWildcardPaths)
for j := 0; j < numOfWildcardPaths; j++ {
pathLen := getPathLen(string(searchData[j].NodePath[:]))
Expand Down Expand Up @@ -636,7 +635,8 @@ func checkifConsent(purpose string) bool {
if pList[i].Short == purpose {
for j := 0; j < len(pList[i].Access); j++ {
validation := -1
golib.VSSsearchNodes(pList[i].Access[j].Path, VSSTreeRoot, MAXFOUNDNODES, true, true, 0, nil, &validation)
VSSTreeRoot := utils.SetRootNodePointer(pList[i].Access[j].Path)
utils.VSSsearchNodes(pList[i].Access[j].Path, VSSTreeRoot, MAXFOUNDNODES, true, true, 0, nil, &validation)
if validation/10 == 1 {
return true
}
Expand Down Expand Up @@ -1318,8 +1318,7 @@ func setExpiryTicker() {
}
}

func AtServerInit(viss2Chan chan string, viss2CancelChan chan string, vssRootReference *gomodel.Node_t, consentSupport bool) {
VSSTreeRoot = vssRootReference
func AtServerInit(viss2Chan chan string, viss2CancelChan chan string, consentSupport bool) {
clientChan := make(chan string)
ecfReceiveChan := make(chan string)
ecfSendChan := make(chan string)
Expand Down
Binary file added server/vissv2server/forest/server.binary
Binary file not shown.
Binary file added server/vissv2server/forest/vss.binary
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
42 changes: 0 additions & 42 deletions server/vissv2server/serverCoreHandlerLib.go

This file was deleted.

26 changes: 23 additions & 3 deletions server/vissv2server/serviceMgr/serviceMgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -989,12 +989,32 @@ func getValidation(path string) string {
return "read-write" //dummy return
}

func configureDefault(udsConn net.Conn) {
defaultFile := "defaultList1.json" //created at server startup if defaults found in any tree.
for i := 2; utils.FileExists(defaultFile); i++ {
data, err := os.ReadFile(defaultFile)
if err != nil {
utils.Error.Printf("configureDefault: Failed to read default configuration from %s with error = %s", defaultFile, err)
return
}
defaultMessage := `{"action": "update", "defaultList": ` + string(data) + "}"
_, err = udsConn.Write([]byte(defaultMessage))
if err != nil {
utils.Error.Printf("configureDefault:Feeder write failed, err = %s", err)
}
os.Remove(defaultFile)
defaultFile = "defaultList" + strconv.Itoa(i) + ".json"
time.Sleep(50 * time.Millisecond) // give feeder some time to process the message sent
}
}

func feederFrontend(toFeeder chan string, fromFeederRorC chan string, fromFeederCl chan string) {
udsConn := utils.GetUdsConn("*", "serverFeeder")
if udsConn == nil {
utils.Error.Printf("feederFrontend:Failed to UDS connect to feeder.")
return // ???
}
configureDefault(udsConn)
fromFeeder := make(chan string)
go feederReader(udsConn, fromFeeder)
feederNotification := "not-verified" // possible alues ["not-verified", "not-supported", "supported"]
Expand Down Expand Up @@ -1315,13 +1335,13 @@ func ServiceMgrInit(mgrId int, serviceMgrChan chan string, stateStorageType stri
subscriptionList := []SubscriptionState{}
subscriptionId = 1 // do not start with zero!

var serverCoreIP string = utils.GetModelIP(2)
/* var serverCoreIP string = utils.GetModelIP(2)
vss_data := getVssPathList(serverCoreIP, 8081, "/vsspathlist")
go initDataServer(serviceMgrChan, dataChan, backendChan)
if historySupport {
go historyServer(historyAccessChannel, vss_data)
}
}*/
go initDataServer(serviceMgrChan, dataChan, backendChan)
toFeeder = make(chan string)
fromFeederRorC = make(chan string)
fromFeederCl = make(chan string)
Expand Down
36 changes: 36 additions & 0 deletions server/vissv2server/viss.him
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
HIM:
type: branch
description: Defines the set of trees that are managed as one virtual domain.


HIM.Vehicle:
type: direct
domain: Vehicle.Car.ResourceData
version: 5.0
local: forest/vss_vissv2.binary
# public: https://himrepo.oem.com?instance=Vehicle.Car.ResourceData.X.Y.Z
description: A VSS tree.

HIM.Vehicle2:
type: direct
domain: Vehicle.Car.ResourceData
version: 5.0
local: forest/vss_vissv2.binary
# public: https://himrepo.oem.com?instance=Vehicle.Car.ResourceData.X.Y.Z
description: Another VSS tree.

HIM.Types:
type: direct
domain: Vehicle.Car.TypeDefinition
version: 0.1
# local: forest/viss_types.binary
# public: https://himrepo.oem.com?instance=Vehicle.Car.DataType.X.Y.Z
description: A type definition tree.

HIM.Server:
type: direct
domain: Server.Capabilities.ResourceData
version: 0.1
local: forest/server.binary
# public: https://himrepo.oem.com?instance=Vehicle.Car.ResourceData.X.Y.Z
description: The server capabilities tree.
Loading

0 comments on commit e093d6b

Please sign in to comment.