syntax = "proto3";

import "google/rpc/status.proto";
import "vme.proto";

option cc_generic_services = true;

package mesytec.mnode.proto.mvlc;

message ReadRegisterRequest
{
    uint32 address = 1;
}

message WriteRegisterRequest
{
    uint32 address = 1;
    uint32 value = 2;
}

message WriteRegisterResponse
{
    optional google.rpc.Status status = 1;
}

message ReadRegisterResponse
{
    optional uint32 value = 1;
    optional google.rpc.Status status = 2;
}

message Buffer
{
    repeated uint32 data = 1;
}

message LowLevelRequest
{
    Buffer contents = 1;
}

message LowLevelResponse
{
    Buffer contents = 1;
}

message CommandRequest
{
    Buffer contents = 1;
};

message CommandResponse
{
    Buffer contents = 1;
};

enum Pipe
{
    Command = 0;
    Data = 1;
}

message WriteRequest
{
    Pipe pipe = 1;
    bytes data = 2;
}

message WriteResponse
{
    google.rpc.Status status = 1;
    uint32 bytes_written = 2;
}

message ReadRequest
{
    Pipe pipe = 1;
    uint32 bytes_to_read = 2;
}

message ReadResponse
{
    google.rpc.Status status = 1;
    bytes data = 2;
}

service MvlcCoreService
{
    rpc Write(WriteRequest) returns (WriteResponse);
    rpc Read(ReadRequest) returns (ReadResponse);
}

service MVLCService
{
    rpc LowLevelTransaction(LowLevelRequest) returns (LowLevelResponse);
    rpc CommandTransaction(CommandRequest) returns (CommandResponse);

    rpc ReadRegister(ReadRegisterRequest) returns (ReadRegisterResponse);
    rpc WriteRegister(WriteRegisterRequest) returns (WriteRegisterResponse);
    rpc VMERead(mesytec.mnode.proto.vme.ReadRequest) returns (mesytec.mnode.proto.vme.ReadResponse);
    rpc VMEWrite(mesytec.mnode.proto.vme.WriteRequest) returns (mesytec.mnode.proto.vme.WriteResponse);
}
