Skip to content

Commit 70e5253

Browse files
Roc: Add SCA_READ RPC to ALF
1 parent 16a62da commit 70e5253

File tree

8 files changed

+54
-8
lines changed

8 files changed

+54
-8
lines changed

src/CommandLineUtilities/AliceLowlevelFrontend/AliceLowlevelFrontend.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,21 @@ class ScaGpioWriteRpc: DimRpcInfoWrapper
245245
}
246246
};
247247

248+
class ScaGpioReadRpc: DimRpcInfoWrapper
249+
{
250+
public:
251+
ScaGpioReadRpc(const std::string& serviceName)
252+
: DimRpcInfoWrapper(serviceName)
253+
{
254+
}
255+
256+
std::string read()
257+
{
258+
setString("");
259+
return stripPrefix(getString());
260+
}
261+
};
262+
248263

249264
class StringRpcServer: public DimRpc
250265
{

src/CommandLineUtilities/AliceLowlevelFrontend/ProgramAliceLowlevelFrontendClient.cxx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,18 @@ class ProgramAliceLowlevelFrontendClient: public Program
7171
Alf::RegisterWriteRpc writeRpc(names.registerWriteRpc());
7272
Alf::ScaReadRpc scaReadRpc(names.scaRead());
7373
Alf::ScaWriteRpc scaWriteRpc(names.scaWrite());
74+
Alf::ScaGpioReadRpc scaGpioReadRpc(names.scaGpioRead());
7475
Alf::ScaGpioWriteRpc scaGpioWriteRpc(names.scaGpioWrite());
7576
Alf::PublishRpc publishRpc(names.publishStartCommandRpc());
7677

7778
publishRpc.publish("ALF/TEST/1", 1.0, {0x1fc});
7879
publishRpc.publish("ALF/TEST/2", 3.0, {0x100, 0x104, 0x108});
7980

8081
for (int i = 0; i < 10; ++i) {
81-
cout << "SCA GPIO write" << endl;
82-
cout << " result: " << scaGpioWriteRpc.write(0x0f0f0f0f) << endl;
82+
cout << "SCA GPIO write '" << i << "'" << endl;
83+
cout << " result: " << scaGpioWriteRpc.write(i) << endl;
84+
cout << "SCA GPIO read" << endl;
85+
cout << " result: " << scaGpioReadRpc.read() << endl;
8386
}
8487

8588
// for (int i = 0; i < 10; ++i) {

src/CommandLineUtilities/AliceLowlevelFrontend/ProgramAliceLowlevelFrontendServer.cxx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,8 @@ class ProgramAliceLowlevelFrontendServer: public Program
244244
[&](auto parameter){return scaRead(parameter, bar2);});
245245
auto serverScaWrite = makeServer(names.scaWrite(),
246246
[&](auto parameter){return scaWrite(parameter, bar2);});
247+
auto serverScaGpioRead = makeServer(names.scaGpioRead(),
248+
[&](auto parameter){return scaGpioRead(parameter, bar2);});
247249
auto serverScaGpioWrite = makeServer(names.scaGpioWrite(),
248250
[&](auto parameter){return scaGpioWrite(parameter, bar2);});
249251

@@ -349,12 +351,12 @@ class ProgramAliceLowlevelFrontendServer: public Program
349351
return "";
350352
}
351353

352-
static std::string scaRead(const std::string& parameter, ChannelSharedPtr bar2)
354+
static std::string scaRead(const std::string&, ChannelSharedPtr bar2)
353355
{
354356
getInfoLogger() << "SCA_READ" << endm;
355357
//auto params = split(parameter, ",");
356358
auto result = Sca(*bar2, bar2->getCardType()).read();
357-
return (b::format("%1%,%2%") % result.data % result.command).str();
359+
return (b::format("%d,%d") % result.data % result.command).str();
358360
}
359361

360362
static std::string scaWrite(const std::string& parameter, ChannelSharedPtr bar2)
@@ -367,12 +369,19 @@ class ProgramAliceLowlevelFrontendServer: public Program
367369
return "";
368370
}
369371

372+
static std::string scaGpioRead(const std::string&, ChannelSharedPtr bar2)
373+
{
374+
getInfoLogger() << "SCA_GPIO_READ" << endm;
375+
auto result = Sca(*bar2, bar2->getCardType()).gpioRead();
376+
return (b::format("%d") % result.data).str();
377+
}
378+
370379
static std::string scaGpioWrite(const std::string& parameter, ChannelSharedPtr bar2)
371380
{
372381
getInfoLogger() << "SCA_GPIO_WRITE: '" << parameter << "'" << endm;
373382
auto data = b::lexical_cast<uint32_t>(parameter);
374383
auto result = Sca(*bar2, bar2->getCardType()).gpioWrite(data);
375-
return (b::format("%x,%x") % result.data % result.command).str();
384+
return (b::format("%d") % result.data).str();
376385
}
377386

378387
int mSerialNumber = 0;

src/CommandLineUtilities/AliceLowlevelFrontend/README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,19 @@ A basic write to the SCA
5050
* Parameters: SCA data, SCA command
5151
* Return: empty
5252

53+
#### SCA GPIO read
54+
Read the GPIO pins
55+
* Service type: RPC call
56+
* Service name: SCA_GPIO_READ
57+
* Parameters:
58+
* Return: SCA data
59+
5360
#### SCA GPIO write
5461
Set enabled the selected GPIO pins
5562
* Service type: RPC call
5663
* Service name: SCA_GPIO_WRITE
5764
* Parameters: SCA data
58-
* Return: SCA data, SCA command
65+
* Return: SCA data
5966

6067
#### Temperature
6168
Card's core temperature in degrees Celsius

src/CommandLineUtilities/AliceLowlevelFrontend/Sca.cxx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ void Sca::write(uint32_t command, uint32_t data)
6060
barWrite(Registers::WRITE_DATA, data);
6161
barWrite(Registers::WRITE_COMMAND, command);
6262
executeCommand();
63-
auto time = barRead(Registers::TIME) * 4;
63+
// auto time = barRead(Registers::TIME) * 4;
6464
// printf("Sca::write DATA=0x%x CH=0x%x TR=0x%x CMD=0x%x TIME(ns)=%u\n", data, command >> 24, (command >> 16) & 0xff,
65-
command & 0xff, time);
65+
// command & 0xff, time);
6666
}
6767

6868
auto Sca::read() -> ReadResult
@@ -136,6 +136,15 @@ auto Sca::gpioWrite(uint32_t data) -> ReadResult
136136
return read();
137137
}
138138

139+
auto Sca::gpioRead() -> ReadResult
140+
{
141+
// printf("Sca::gpioRead\n", data);
142+
// RD DATA
143+
write(0x02050011, 0x0);
144+
return read();
145+
}
146+
147+
139148
void Sca::barWrite(int index, uint32_t data)
140149
{
141150
bar2.writeRegister(index + offset, data);

src/CommandLineUtilities/AliceLowlevelFrontend/Sca.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class Sca
3737
void initialize();
3838
void write(uint32_t command, uint32_t data);
3939
ReadResult read();
40+
ReadResult gpioRead();
4041
ReadResult gpioWrite(uint32_t data);
4142

4243
private:

src/CommandLineUtilities/AliceLowlevelFrontend/ServiceNames.cxx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ DEFSERVICENAME(publishStopCommandRpc, "PUBLISH_SERVICE_STOP")
2424
DEFSERVICENAME(scaRead, "SCA_READ")
2525
DEFSERVICENAME(scaWrite, "SCA_WRITE")
2626
DEFSERVICENAME(scaGpioWrite, "SCA_GPIO_WRITE")
27+
DEFSERVICENAME(scaGpioRead, "SCA_GPIO_READ")
2728
DEFSERVICENAME(temperature, "TEMPERATURE")
2829

2930
std::string ServiceNames::format(std::string name) const

src/CommandLineUtilities/AliceLowlevelFrontend/ServiceNames.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class ServiceNames
2828
std::string scaWrite() const;
2929
std::string scaRead() const;
3030
std::string scaGpioWrite() const;
31+
std::string scaGpioRead() const;
3132
std::string temperature() const;
3233

3334
private:

0 commit comments

Comments
 (0)