Author Topic: Oak CLI will not log into Particle  (Read 5991 times)

exeng

  • Sr. Member
  • ****
  • Posts: 454
Re: Oak CLI will not log into Particle
« Reply #15 on: December 15, 2016, 09:53:55 am »
OK... Fired up my WIN 10 system. It had Arduino 1.6.7 installed but no Oak boards. Installed the Oak (1.0.6). Ran OakCLI (1.0.2) from the tools directory and bam logged into Particle without issue.
So, what's up with pkourany's problem?

PeterF

  • Hero Member
  • *****
  • Posts: 883
Re: Oak CLI will not log into Particle
« Reply #16 on: December 15, 2016, 08:45:58 pm »
After persuading pkourany to let me root around his in his particle account  ;D... it seems we are getting warmer. He has some 34 devices on his account, and OakCLI seems to be having a hissy fit over that. He was able to log into my account with OakCLI without issues, but I wasn't able to log into his, and got the same error message.

Ater shoving in a number of console.log messages to work my way through the oakcli execution... it fell flat on it's face at line 303... where it is looking for input... so now to work out WHY it is being such a little pain.

Code: [Select]
        index = readlineSync.keyInSelect(devicesList, 'Which device would you like to use?', {cancel: 'Exit'});
Digging through the code a bit more, it appears that if you prevent the OakCLI from processing more than 32 devices, everything is good. As soon as it gets to the 33rd device... it crashes 'n burns... If 32 is a magic number I don't know... maybe it's just two less than what are on the account?  ???

Anyway, inserting the below after line 288 in the oak.js source has mitigated the issue, but not fixed it. Oak CLI is now running, but there will be two devices missing in this instance. https://github.com/digistump/OakCLI/blob/master/oak.js#L288

Code: [Select]
  if (i == 32) // any more and OakCLI crashes :-O
  {
  console.log('reached '+i+' devices')
  break;
  }
« Last Edit: December 15, 2016, 08:53:19 pm by PeterF »

exeng

  • Sr. Member
  • ****
  • Posts: 454
Re: Oak CLI will not log into Particle
« Reply #17 on: December 15, 2016, 08:58:54 pm »
Pete you are the best mate. If you recall there was a error message in one of pkourany's early post complaining
Quote
OakCLI tool version 1.0.2

nexe.js:43674
    { throw '`items` must be Array (max length: 35).'; }
      ^
`items` must be Array (max length: 35).

While 32 and 35 are not the same, I wonder if it is a limitation in nexe.js?

PeterF

  • Hero Member
  • *****
  • Posts: 883
Re: Oak CLI will not log into Particle
« Reply #18 on: December 15, 2016, 09:18:26 pm »
I don't think so... this was happening when I was running the raw oak.js through node... I didn't bother compiling it to exe via nexe. So I was getting a slightly different message when running it that way (below). But I did get the same one as pkourany did when I ran the compiled EXE.

Code: [Select]
C:\Users\Peter\Desktop\OakCLI\node_modules\readline-sync\lib\readline-sync.js:1263
    throw '`items` must be Array (max length: 35).';
    ^
`items` must be Array (max length: 35).

It was the 35 that was bugging me, since there were 34 devices in the list... then I realised that the devicesList variable that is being passed in at the line that is failing contains all the output to the screen shown as part of the menu, so will have some 34+3 or so lines... so maybe the real problem is that  readlineSync.keyInSelect() can't take an array containing more than 35 entries?

Edit: No need to guess.... it does have a maximum of 35.


« Last Edit: December 15, 2016, 09:20:26 pm by PeterF »

exeng

  • Sr. Member
  • ****
  • Posts: 454
Re: Oak CLI will not log into Particle
« Reply #19 on: December 15, 2016, 09:27:54 pm »
Bam, you the man. I know you were nominated for a "god" title but that position is taken. You are however fast approaching the Dr. Pete title. Great to have someone with your persistence and knowledge on the forum.

PeterF

  • Hero Member
  • *****
  • Posts: 883
Re: Oak CLI will not log into Particle
« Reply #20 on: December 15, 2016, 09:58:17 pm »
lol... I think you just mean persistence... and desire to not do any more study on assignments... that might be the motivation there ;-P

I try though... (yes, I am a very 'trying' person)  :P  :o

pkourany

  • Newbie
  • *
  • Posts: 25
Re: Oak CLI will not log into Particle
« Reply #21 on: December 30, 2016, 10:36:26 am »
Peter,

Who will fix this? I guess the only way to use this is to create a new Particle account and put only my Oaks on there.  Argh!

PeterF

  • Hero Member
  • *****
  • Posts: 883
Re: Oak CLI will not log into Particle
« Reply #22 on: December 31, 2016, 01:27:14 am »
In the short term, yes, that is probably the workaround for the present time. Otherwise, it will be Erik or anyone who wants to fix it since all the code is up on github. I'd do it, but I don't know enough nodejs... so if I take it on it will take a while... a very long while!

Basically, the devicesList needs to be parsed into smaller groups for display/input handling, so that the readlineSync.keyInSelect() limit of 35 entries isn't exceeded. So it would be something like 10-15 devices at a time, and you'd have two extra menu entries that allow between the groups. Or something else used that doesn't have a 35 entry limit... but in reality that allows the menu to become ridiculously long.


pkourany

  • Newbie
  • *
  • Posts: 25
Re: Oak CLI will not log into Particle
« Reply #23 on: December 31, 2016, 05:27:35 pm »
Peter, I believe the OakCLI could be modified to use term-list-scrollable (see https://www.npmjs.com/package/term-list-scrollable) to replace readlineSync.  I don't care to setup the entire toolchain necessary to make the code for Windows.  Hopefully, Erik or another can take this and run with it.

PeterF

  • Hero Member
  • *****
  • Posts: 883
Re: Oak CLI will not log into Particle
« Reply #24 on: December 31, 2016, 06:44:42 pm »
Hm... that looks promising... No promises yet  ;D but I'll look into that ... I'm running node on my desktop so can at least get the node code updated it isn't too painless.

pkourany

  • Newbie
  • *
  • Posts: 25
Re: Oak CLI will not log into Particle
« Reply #25 on: January 03, 2017, 05:12:32 am »
Thanks Peter!