frg-fossee / eSim-Cloud

A web-based system for designing and simulating electronic (eSim) and Arduino circuits.

Home Page:https://esim-cloud.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

BreadBoard Issue in Arduino on cloud

ikartikgautam opened this issue · comments

PROBLEM

Description: BreadBoard has some issue in it, and does give errors sometimes.

Tested on: macOS develop branch & live website
How to reproduce the error:
1. Replicate the circuit with the code below (you can try with other circuits also)
2. Click on the "start simulation" button
3. If an error does not persist then clear the circuit and replicate the circuit again(as this error occurs randomly).

  1. Take out one BreadBoard from left panel
  2. Move it somewhere by dragging it.
  3. Click on 'Start Sinulation'.

TESTING

Circuit: [NOT NEEDED]
Screenshot 2021-06-26 at 1 53 20 PM

Console Error(Prod):
Screenshot 2021-06-26 at 1 52 37 PM

Console Error(Dev):
Screenshot 2021-06-26 at 1 55 14 PM

Code: [NOT NEEDED]
`
int LED_PIN = 10;
void setup(){
pinMode(LED_PIN, OUTPUT);
}

void loop(){
digitalWrite(LED_PIN, HIGH);
delay(1000);
}
`

REASON

I did a bit of debugging and found that it is caused by Breadboard in General.ts. the issue is caused because the sameXNodes & sameYNodes aren't getting created as expected every time. Technically these arrays should consist of nodes with similar x & y coordinates in their respective keys (see below image).
Screenshot 2021-06-26 at 2 05 39 PM
In Above image, you can observe that the key is matching with y coordinates in its items too. But if I consider error one then,
Screenshot 2021-06-26 at 2 08 44 PM
the key is not matching the y coordinates in the array.
Due to this error shows up, ultimately stopping the application.

The error is throwing up in the General.ts in the init() function.

I did try a bit to fix this but can't find really why this change is happening in keys, at the moment i think its completely random, as i tried every bit to find the exact cause of the problem,

UPDATE

The issue is being caused due to dragging on breadboard. The closest guess is that sameXNode and sameYNode variable are not able to retain the change in node's coordinates

TEMPORARY FIX:

One working fix to this issue is to either export the circuit or save it, and then import the circuit again after refreshing page. A new imported circuit never gives this error.