Change in osmo-ccid-firmware[master]: Add various SIM card related debug command

2019-02-27 Thread Kévin Redon
Kévin Redon has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/13037 )

Change subject: Add various SIM card related debug command
..

Add various SIM card related debug command

this allows commands like
 sim-status 0   # read the status
 sim-voltage 0 5# set voltage to 5V
 sim-clkdiv 0 2 # set clock-divider to 2 (10 MHz)
 sim-reset 0 0  # disable reset
 sim-power 0 1  # enable power

Change-Id: Id6131be60d37cba769c79952fa44f3ec6c976a38
---
M sysmoOCTSIM/main.c
M sysmoOCTSIM/ncn8025.c
M sysmoOCTSIM/ncn8025.h
3 files changed, 193 insertions(+), 0 deletions(-)

Approvals:
  Jenkins Builder: Verified
  Kévin Redon: Looks good to me, approved



diff --git a/sysmoOCTSIM/main.c b/sysmoOCTSIM/main.c
index ef87162..dc67406 100644
--- a/sysmoOCTSIM/main.c
+++ b/sysmoOCTSIM/main.c
@@ -16,6 +16,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, 
USA.
 */

+#include 
+#include 
 #include 
 #include 
 #include 
@@ -55,6 +57,163 @@
printf("Hello World!\r\n");
 }

+static int validate_slotnr(int argc, char **argv, int idx)
+{
+   int slotnr;
+   if (argc < idx+1) {
+   printf("You have to specify the slot number (0..7)\r\n");
+   return -1;
+   }
+   slotnr = atoi(argv[idx]);
+   if (slotnr < 0 || slotnr > 7) {
+   printf("You have to specify the slot number (0..7)\r\n");
+   return -1;
+   }
+   return slotnr;
+}
+
+DEFUN(sim_status, cmd_sim_status, "sim-status", "Get state of specified 
NCN8025")
+{
+   struct ncn8025_settings settings;
+   int slotnr = validate_slotnr(argc, argv, 1);
+   if (slotnr < 0)
+   return;
+   ncn8025_get(slotnr, );
+   printf("SIM%d: ", slotnr);
+   ncn8025_dump();
+   printf("\r\n");
+}
+
+DEFUN(sim_power, cmd_sim_power, "sim-power", "Enable/disable SIM card power")
+{
+   struct ncn8025_settings settings;
+   int slotnr = validate_slotnr(argc, argv, 1);
+   int enable;
+
+   if (slotnr < 0)
+   return;
+
+   if (argc < 3) {
+   printf("You have to specify 0=disable or 1=enable\r\n");
+   return;
+   }
+   enable = atoi(argv[2]);
+   ncn8025_get(slotnr, );
+   if (enable)
+   settings.cmdvcc = true;
+   else
+   settings.cmdvcc = false;
+   ncn8025_set(slotnr, );
+}
+
+DEFUN(sim_reset, cmd_sim_reset, "sim-reset", "Enable/disable SIM reset")
+{
+   struct ncn8025_settings settings;
+   int slotnr = validate_slotnr(argc, argv, 1);
+   int enable;
+
+   if (slotnr < 0)
+   return;
+
+   if (argc < 3) {
+   printf("You have to specify 0=disable or 1=enable\r\n");
+   return;
+   }
+   enable = atoi(argv[2]);
+   ncn8025_get(slotnr, );
+   if (enable)
+   settings.rstin = true;
+   else
+   settings.rstin = false;
+   ncn8025_set(slotnr, );
+}
+
+DEFUN(sim_clkdiv, cmd_sim_clkdiv, "sim-clkdiv", "Set SIM clock divider 
(1,2,4,8)")
+{
+   struct ncn8025_settings settings;
+   int slotnr = validate_slotnr(argc, argv, 1);
+   int clkdiv;
+
+   if (slotnr < 0)
+   return;
+
+   if (argc < 3) {
+   printf("You have to specify a valid divider (1,2,4,8)\r\n");
+   return;
+   }
+   clkdiv = atoi(argv[2]);
+   if (clkdiv != 1 && clkdiv != 2 && clkdiv != 4 && clkdiv != 8) {
+   printf("You have to specify a valid divider (1,2,4,8)\r\n");
+   return;
+   }
+   ncn8025_get(slotnr, );
+   switch (clkdiv) {
+   case 1:
+   settings.clkdiv = SIM_CLKDIV_1;
+   break;
+   case 2:
+   settings.clkdiv = SIM_CLKDIV_2;
+   break;
+   case 4:
+   settings.clkdiv = SIM_CLKDIV_4;
+   break;
+   case 8:
+   settings.clkdiv = SIM_CLKDIV_8;
+   break;
+   }
+   ncn8025_set(slotnr, );
+}
+
+DEFUN(sim_voltage, cmd_sim_voltage, "sim-voltage", "Set SIM voltage (5/3/1.8)")
+{
+   struct ncn8025_settings settings;
+   int slotnr = validate_slotnr(argc, argv, 1);
+
+   if (slotnr < 0)
+   return;
+
+   if (argc < 3) {
+   printf("You have to specify a valid voltage (5/3/1.8)\r\n");
+   return;
+   }
+   ncn8025_get(slotnr, );
+   if (!strcmp(argv[2], "5"))
+   settings.vsel = SIM_VOLT_5V0;
+   else if (!strcmp(argv[2], "3"))
+   settings.vsel = SIM_VOLT_3V0;
+   else if (!strcmp(argv[2], "1.8"))
+   settings.vsel = SIM_VOLT_1V8;
+   else {
+   printf("You have to specify a valid voltage (5/3/1.8)\r\n");
+   return;
+   }
+   ncn8025_set(slotnr, );
+}
+
+DEFUN(sim_led, 

Change in osmo-ccid-firmware[master]: Add various SIM card related debug command

2019-02-27 Thread Kévin Redon
Kévin Redon has posted comments on this change. ( 
https://gerrit.osmocom.org/13037 )

Change subject: Add various SIM card related debug command
..


Patch Set 3: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/13037
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Id6131be60d37cba769c79952fa44f3ec6c976a38
Gerrit-Change-Number: 13037
Gerrit-PatchSet: 3
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Kévin Redon 
Gerrit-Comment-Date: Wed, 27 Feb 2019 13:22:01 +
Gerrit-HasComments: No
Gerrit-HasLabels: Yes


Change in osmo-ccid-firmware[master]: Add various SIM card related debug command

2019-02-24 Thread Harald Welte
Hello Jenkins Builder,

I'd like you to reexamine a change. Please visit

https://gerrit.osmocom.org/13037

to look at the new patch set (#3).

Change subject: Add various SIM card related debug command
..

Add various SIM card related debug command

this allows commands like
 sim-status 0   # read the status
 sim-voltage 0 5# set voltage to 5V
 sim-clkdiv 0 2 # set clock-divider to 2 (10 MHz)
 sim-reset 0 0  # disable reset
 sim-power 0 1  # enable power

Change-Id: Id6131be60d37cba769c79952fa44f3ec6c976a38
---
M sysmoOCTSIM/main.c
M sysmoOCTSIM/ncn8025.c
M sysmoOCTSIM/ncn8025.h
3 files changed, 193 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-ccid-firmware 
refs/changes/37/13037/3
--
To view, visit https://gerrit.osmocom.org/13037
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Id6131be60d37cba769c79952fa44f3ec6c976a38
Gerrit-Change-Number: 13037
Gerrit-PatchSet: 3
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)


Change in osmo-ccid-firmware[master]: Add various SIM card related debug command

2019-02-24 Thread Harald Welte
Hello Jenkins Builder,

I'd like you to reexamine a change. Please visit

https://gerrit.osmocom.org/13037

to look at the new patch set (#2).

Change subject: Add various SIM card related debug command
..

Add various SIM card related debug command

this allows commands like
 sim-status 0   # read the status
 sim-voltage 0 5# set voltage to 5V
 sim-clkdiv 0 2 # set clock-divider to 2 (10 MHz)
 sim-reset 0 0  # disable reset
 sim-power 0 1  # enable power

Change-Id: Id6131be60d37cba769c79952fa44f3ec6c976a38
---
M sysmoOCTSIM/main.c
M sysmoOCTSIM/ncn8025.c
M sysmoOCTSIM/ncn8025.h
3 files changed, 170 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-ccid-firmware 
refs/changes/37/13037/2
--
To view, visit https://gerrit.osmocom.org/13037
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Id6131be60d37cba769c79952fa44f3ec6c976a38
Gerrit-Change-Number: 13037
Gerrit-PatchSet: 2
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)