### info
Source: https://lcgamboa.github.io/picsimlab_docs/stable/RemoteControlInterface.html
Shows the actual setup information and all available objects with their values.
```APIDOC
## info
### Description
Displays the board setup, processor, frequency, and all objects (inputs/outputs) with their current values.
### Method
TCP command
### Endpoint
Remote control interface (TCP port 5000)
### Parameters
None
### Request Example
```
info
```
### Response
#### Success Response
Board information and object values.
#### Response Example
```
Board: Arduino Uno
Processor: atmega328p
Frequency: 16000000 Hz
Use Spare: 1
board.out[00] LD_L= 254
part[00]: LEDs
part[00].out[08] LD_1= 254
part[00].out[09] LD_2= 30
part[00].out[10] LD_3= 254
part[00].out[11] LD_4= 254
part[00].out[12] LD_5 254
part[00].out[13] LD_6= 254
part[00].out[14] LD_7= 254
part[01]: Buzzer
part[01].out[02] LD_1= 140
part[02]: Push buttons
part[02].in[00] PB_1= 1
part[02].in[01] PB_2= 0
part[02].in[02] PB_3= 1
part[02].in[03] PB_4= 1
part[02].in[04] PB_5= 1
part[02].in[05] PB_6= 1
part[02].in[06] PB_7= 1
part[02].in[07] PB_8= 1
Ok
```
```
--------------------------------
### Get object values with get command
Source: https://lcgamboa.github.io/picsimlab_docs/stable/RemoteControlInterface.html
Shows how to retrieve the value of an object (e.g., board output or part input) using the get command.
```text
get board.out[00]
get part[02].in[01]
```
--------------------------------
### Install tty0tty module with dkms-install.sh
Source: https://lcgamboa.github.io/picsimlab_docs/stable/tty0ttyInstallationandConfigurationLinux.html
Run these commands in the tty0tty/module/ folder to update the system, install build tools and kernel headers, then build and load the tty0tty kernel module.
```bash
sudo apt-get update
sudo apt-get -y upgrade
sudo apt-get -y install gcc make linux-headers-`uname -r`
sudo ./dkms-install.sh
sudo modprobe tty0tty
```
--------------------------------
### PIC C code example for test.c
Source: https://lcgamboa.github.io/picsimlab_docs/stable/CodeExample.html
Paste this code into test.c. It configures all PORTB pins as outputs, turns them off, then in an infinite loop turns RB0 and RB1 on and then turns all pins off.
```c
void main()
{
TRISB=0x00; //All pins as output
PORTB=0; //All pins off
while(1) //main loop
{
PORTBbits.RB0=1; //Turn RB0 on
PORTBbits.RB1=1; //Turn RB1 on
PORTB=0; //All pins off
}
}
```
--------------------------------
### Launch avr-gdb with compiled .elf file
Source: https://lcgamboa.github.io/picsimlab_docs/stable/avrgdbDebug.html
Run avr-gdb with the compiled .elf file as the parameter to start debugging in PicsimLab.
```bash
avr-gdb compiled_file.elf
```
--------------------------------
### Get individual pin states with get variants
Source: https://lcgamboa.github.io/picsimlab_docs/stable/RemoteControlInterface.html
Shows how to retrieve digital, mean, analog, and full info for individual pins using get pin, get pinm, get apin, and get pinl.
```text
#digital state
get pin[19]
pin[19]= 0
Ok
#digital mean value (0-200)
get pinm[19]
pin[18]= 100
Ok
#analog state
get apin[25]
apin[25]= 2.700
Ok
#all info
get pinl[13]
pin[13] D I 1 200 0.000 "PD7/7 "
Ok
```
--------------------------------
### cboard_x::Run_CPU - function start
Source: https://lcgamboa.github.io/picsimlab_docs/stable/Boardcode.html
Starts the Run_CPU method for the board. Declares local variables including an array alm of 40 unsigned ints. The visible portion is only the function signature and initial declarations.
```cpp
void
cboard_x::Run_CPU(void)
{
int i;
int j;
unsigned char pi;
const picpin * pins;
unsigned int alm[40];
```
--------------------------------
### Connect arm-none-eabi-gdb to PICSimLab
Source: https://lcgamboa.github.io/picsimlab_docs/stable/armgdbDebug.html
Start arm-none-eabi-gdb with the compiled .elf file, then connect to the PICSimLab debug server on localhost port 1234 (the default port).
```bash
arm-none-eabi-gdb compiled_file.elf
```
```gdb
target extended-remote localhost:1234
```
--------------------------------
### Launch xtensa-esp32-elf-gdb with the compiled ELF file
Source: https://lcgamboa.github.io/picsimlab_docs/stable/ESP32gdbDebug.html
Run the GDB debugger with the compiled .elf file as the argument to start debugging the code used in the simulator.
```bash
xtensa-esp32-elf-gdb compiled_file.elf
```
--------------------------------
### Board map file example (board.map)
Source: https://lcgamboa.github.io/picsimlab_docs/stable/Picturemap.html
Example of a board.map file generated by Gimp image map editor. It defines clickable areas (rectangles and circles) with coordinates and href identifiers matching the board areas listed above. The file is saved as 'share/boards/X/board.map'.
```html
```
--------------------------------
### board_x.cc: PICSimLab board main loop and registration
Source: https://lcgamboa.github.io/picsimlab_docs/stable/Boardcode.html
Main loop of the board_x.cc example: reads step counts, resets pin mean values, processes spare parts and oscilloscope windows, steps the PIC while respecting breakpoints, accumulates pin values, sets analog pin AN0 from a potentiometer, computes mean output values, updates LED and RB output IDs, and finally registers the board with board_init().
```C++
int JUMPSTEPS = Window1.GetJUMPSTEPS (); //number of steps skipped
long int NSTEP = Window1.GetNSTEP () / MGetPinCount (); //number of steps in 100ms
//reset pins mean value
memset (alm, 0, 40 * sizeof (unsigned int));
//read pic.pins to a local variable to speed up
pins = pic.pins;
//Spare parts window pre process
if (use_spare)Window5.PreProcess ();
j = JUMPSTEPS; //step counter
if (Window1.Get_mcupwr ()) //if powered
for (i = 0; i < Window1.GetNSTEP (); i++) //repeat for number of steps in 100ms
{
if (j >= JUMPSTEPS)//if number of step is bigger than steps to skip
{
pic_set_pin (pic.mclr, p_RST);
pic_set_pin (19, p_BT1); //Set pin 19 (RD0) with button state
pic_set_pin (20, p_BT2); //Set pin 20 (RD1) with switch state
}
//verify if a breakpoint is reached if not run one instruction
if (!mplabxd_testbp ())pic_step ();
//Oscilloscope window process
if (use_oscope)Window4.SetSample ();
//Spare parts window process
if (use_spare)Window5.Process ();
//increment mean value counter if pin is high
alm[i % pic.PINCOUNT] += pins[i % pic.PINCOUNT].value;
if (j >= JUMPSTEPS)//if number of step is bigger than steps to skip
{
//set analog pin 2 (AN0) with value from scroll
pic_set_apin (2, (5.0 * pot1 / 199));
j = - 1; //reset counter
}
j++; //counter increment
}
//calculate mean value
for (pi = 0; pi < pic.PINCOUNT; pi++)
{
pic.pins[pi].oavalue = (int) (((200.0 * alm[pi]) / NSTEP) + 55);
}
//Spare parts window pre post process
if (use_spare)Window5.PostProcess ();
//verifiy if LEDS need update
if (output_ids[O_LD0]- >value != pic.pins[18].oavalue)
{
output_ids[O_LD0]- >value = pic.pins[18].oavalue;
output_ids[O_LD0]- >update = 1;
}
if (output_ids[O_LD1]- >value != pic.pins[19].oavalue)
{
output_ids[O_LD1]- >value = pic.pins[19].oavalue;
output_ids[O_LD1]- >update = 1;
}
if (output_ids[O_RB0]- >value != pic.pins[32].oavalue)
{
output_ids[O_RB0]- >value = pic.pins[32].oavalue;
output_ids[O_RB0]- >update = 1;
}
if (output_ids[O_RB1]- >value != pic.pins[33].oavalue)
{
output_ids[O_RB1]- >value = pic.pins[33].oavalue;
output_ids[O_RB1]- >update = 1;
}
}
//Register the board in PICSimLab
board_init(BOARD_x_Name, cboard_x);
```
--------------------------------
### Build experimental version with build scripts
Source: https://lcgamboa.github.io/picsimlab_docs/stable/Experimentalversion.html
Build the experimental version using the 'exp' parameter with the provided build scripts. Run these commands from the project root.
```bash
bscripts/build_all_and_install.sh exp
bscripts/build_w64.sh exp
bscripts/build_w32.sh exp
```
--------------------------------
### get
Source: https://lcgamboa.github.io/picsimlab_docs/stable/RemoteControlInterface.html
Gets the value of an object or pin.
```APIDOC
## get
### Description
Retrieves the current value of a specified object or pin. Supports objects like board.out[00] and part[02].in[01], and pins like pin[19], pinm[19], apin[25], and pinl[13].
### Method
TCP command
### Endpoint
Remote control interface (TCP port 5000)
### Parameters
- **ob** (string) - Required - The object or pin identifier to query.
### Request Example
```
get board.out[00]
```
### Response
#### Success Response
Returns the value of the specified object or pin.
#### Response Example
```
get pin[19]
pin[19]= 0
Ok
```
#### Response Example (digital mean)
```
get pinm[19]
pin[18]= 100
Ok
```
#### Response Example (analog)
```
get apin[25]
apin[25]= 2.700
Ok
```
#### Response Example (all info)
```
get pinl[13]
pin[13] D I 1 200 0.000 "PD7/7 "
Ok
```
```
--------------------------------
### Initial build for Windows 64-bit
Source: https://lcgamboa.github.io/picsimlab_docs/stable/Windows.html
Clones the PICSIMLab repository and runs the build script for Windows 64-bit targets. Use this on Debian Linux or WSL for the first build.
```bash
git clone https://github.com/lcgamboa/picsimlab.git
cd picsimlab
bscripts/build_w64.sh
```
--------------------------------
### Initial build for Windows 32-bit
Source: https://lcgamboa.github.io/picsimlab_docs/stable/Windows.html
Clones the PICSIMLab repository and runs the build script for Windows 32-bit targets. Use this on Debian Linux or WSL for the first build.
```bash
git clone https://github.com/lcgamboa/picsimlab.git
cd picsimlab
bscripts/build_w32.sh
```
--------------------------------
### First-time build on Debian Linux
Source: https://lcgamboa.github.io/picsimlab_docs/stable/Linux.html
First-time build for Debian Linux and derivatives. Requires a user with sudo permission. Clones the repository, changes into the picsimlab directory, and runs the build-and-install script.
```shell
git clone --depth=1 https://github.com/lcgamboa/picsimlab.git
cd picsimlab
bscripts/build_all_and_install.sh
```
--------------------------------
### Set pin values with set command
Source: https://lcgamboa.github.io/picsimlab_docs/stable/RemoteControlInterface.html
Shows how to set digital and analog pin values using set pin and set apin.
```text
#digital
set pin[10] 2
#analog
set apin[20] 2.345
```
--------------------------------
### Show objects and values with info
Source: https://lcgamboa.github.io/picsimlab_docs/stable/RemoteControlInterface.html
Displays the board, processor, frequency, and all available objects with their current values.
```text
info
Board: Arduino Uno
Processor: atmega328p
Frequency: 16000000 Hz
Use Spare: 1
board.out[00] LD_L= 254
part[00]: LEDs
part[00].out[08] LD_1= 254
part[00].out[09] LD_2= 30
part[00].out[10] LD_3= 254
part[00].out[11] LD_4= 254
part[00].out[12] LD_5 254
part[00].out[13] LD_6= 254
part[00].out[14] LD_7= 254
part[01]: Buzzer
part[01].out[02] LD_1= 140
part[02]: Push buttons
part[02].in[00] PB_1= 1
part[02].in[01] PB_2= 0
part[02].in[02] PB_3= 1
part[02].in[03] PB_4= 1
part[02].in[04] PB_5= 1
part[02].in[05] PB_6= 1
part[02].in[06] PB_7= 1
part[02].in[07] PB_8= 1
Ok
```
--------------------------------
### tty0tty port mapping
Source: https://lcgamboa.github.io/picsimlab_docs/stable/tty0ttyInstallationandConfigurationLinux.html
Shows the four interconnected port pairs created by the tty0tty module after installation.
```text
/dev/tnt0 <=> /dev/tnt1
/dev/tnt2 <=> /dev/tnt3
/dev/tnt4 <=> /dev/tnt5
/dev/tnt6 <=> /dev/tnt7
```
--------------------------------
### Show supported commands with help
Source: https://lcgamboa.github.io/picsimlab_docs/stable/RemoteControlInterface.html
Displays the list of supported remote control commands and their descriptions.
```text
help
List of supported commands:
dumpe [a] [s]- dump internal EEPROM memory
dumpf [a] [s]- dump Flash memory
dumpr [a] [s]- dump RAM memory
exit - shutdown PICSimLab
get ob - get object value
help - show this message
info - show actual setup info and objects
loadhex file - load hex file (use full path)
pins - show pins directions and values
pinsl - show pins formated info
quit - exit remote control interface
reset - reset the board
set ob vl - set object with value
sim [cmd] - show simulation status or execute cmd start/stop
sync - wait to syncronize with timer event
version - show PICSimLab version
Ok
```
--------------------------------
### Load binary file with picsimlab_tool
Source: https://lcgamboa.github.io/picsimlab_docs/stable/picsimlabtool.html
Use this command to load a binary file into boards based on ESP32 or STM32 after opening PICSimLab.
```bash
picsimlab_tool loadbin file.bin
```
--------------------------------
### PlatformIO configuration for ESP32-gdb debug in VSCode
Source: https://lcgamboa.github.io/picsimlab_docs/stable/ESP32gdbDebug.html
Add these lines to the project's platformio.ini file to enable graphical debug mode in VSCode. It sets a custom upload command for PICSimLab, enables debug build, and defines debug initialization commands. Compile and upload the code to PICSimLab before starting Debug.
```ini
;upload_protocol = esptool
;upload_port = COM7
;upload_port = /dev/tnt2
upload_protocol = custom
upload_command = C:\"Program Files\"\PicsimLab\picsimlab_tool.exe loadbin \"$BUILD_DIR/firmware.bin\"
;upload_command = /usr/bin/picsimlab_tool loadbin \"$BUILD_DIR/firmware.bin\"
build_type = debug
debug_tool = custom
debug_port = localhost:1234
debug_build_flags = -O2 -g
debug_init_break = tbreak main
debug_init_cmds =
define pio_reset_halt_target
monitor system_reset
end
define pio_reset_run_target
monitor system_reset
end
target extended-remote $DEBUG_PORT
$LOAD_CMDS
pio_reset_halt_target
$INIT_BREAK
```
--------------------------------
### Recompile experimental version with Makefiles
Source: https://lcgamboa.github.io/picsimlab_docs/stable/Experimentalversion.html
Recompile the experimental version using the 'exp' parameter with the provided Makefiles. Use the appropriate Makefile for your target platform.
```makefile
make -j4 exp
make FILE=Makefile.cross -j4 exp
make FILE=Makefile.cross_32 -j4 exp
```
--------------------------------
### help
Source: https://lcgamboa.github.io/picsimlab_docs/stable/RemoteControlInterface.html
Displays the list of supported commands in the remote control interface.
```APIDOC
## help
### Description
Shows the list of supported commands.
### Method
TCP command
### Endpoint
Remote control interface (TCP port 5000)
### Parameters
None
### Request Example
```
help
```
### Response
#### Success Response
List of supported commands.
#### Response Example
```
List of supported commands:
dumpe [a] [s]- dump internal EEPROM memory
dumpf [a] [s]- dump Flash memory
dumpr [a] [s]- dump RAM memory
exit - shutdown PICSimLab
get ob - get object value
help - show this message
info - show actual setup info and objects
loadhex file - load hex file (use full path)
pins - show pins directions and values
pinsl - show pins formated info
quit - exit remote control interface
reset - reset the board
set ob vl - set object with value
sim [cmd] - show simulation status or execute cmd start/stop
sync - wait to syncronize with timer event
version - show PICSimLab version
Ok
```
```
--------------------------------
### Set object values with set command
Source: https://lcgamboa.github.io/picsimlab_docs/stable/RemoteControlInterface.html
Shows how to set the value of an object (e.g., a push button input) using the set command.
```text
set part[02].in[01] 0
set part[02].in[01] 1
```
--------------------------------
### cboard_x board event handling and preferences
Source: https://lcgamboa.github.io/picsimlab_docs/stable/Boardcode.html
Implements the cboard_x class methods for saving/reading preferences, handling keyboard and mouse events, and updating output IDs. The code shows how to persist switch, clock, and potentiometer values, and how to respond to key presses and mouse events on the board.
```cpp
//write switch state of board_x to preferences
Window1.saveprefs (lxT ("X_bt2"), lxString ().Format ("%i", p_BT2));
//write microcontroller clock to preferences
Window1.saveprefs (lxT ("X_clock"), lxString ().Format ("%2.1f", Window1.GetClock ()));
//write potentiometer position to preferences
Window1.saveprefs (lxT ("X_pot1"), lxString ().Format ("%i", pot1));
}
//Called whe configuration file load preferences
void
cboard_x::ReadPreferences(char *name, char *value)
{
//read switch state of board_x of preferences
if (!strcmp (name, "X_bt2"))
{
if (value[0] == '0')
p_BT2 = 0;
else
p_BT2 = 1;
}
//read microcontroller of preferences
if (!strcmp (name, "X_proc"))
{
Proc = value;
}
//read microcontroller clock
if (!strcmp (name, "X_clock"))
{
Window1.SetClock (atof (value));
}
//read potentiometer position
if (!strcmp (name, "X_pot1"))
{
pot1 = atoi (value);
}
}
//Event on the board
void
cboard_x::EvKeyPress(uint key, uint mask)
{
//if keyboard key 1 is pressed then activate button (state=0)
if (key == '1')
{
p_BT1 = 0;
output_ids[O_BD0]- >update = 1;
}
//if keyboard key 2 is pressed then toggle switch state
if (key == '2')
{
p_BT2 ^= 1;
output_ids[O_SD1]- >update = 1;
}
}
//Event on the board
void
cboard_x::EvMouseButtonPress(uint button, uint x, uint y, uint state)
{
int i;
//search for the input area which owner the event
for (i = 0; i < inputc; i++)
{
if (((input[i].x1 <= x)&&(input[i].x2 >= x))&&((input[i].y1 <= y)&&
(input[i].y2 >= y)))
{
switch (input[i].id)
{
//if event is over I_ISCP area then load hex file
case I_ICSP:
Window1.menu1_File_LoadHex_EvMenuActive (NULL);
break;
//if event is over I_PWR area then toggle board on/off
case I_PWR:
if (Window1.Get_mcupwr ()) //if on turn off
{
Window1.Set_mcurun (0);
Window1.Set_mcupwr (0);
Reset ();
p_BT1 = 1;
Window1.statusbar1.SetField (0, lxT ("Stoped"));
}
else //if off turn on
{
Window1.Set_mcupwr (1);
Window1.Set_mcurun (1);
Reset ();
Window1.statusbar1.SetField (0, lxT ("Running..."));
}
output_ids[O_LPWR]- >update = 1;
break;
//if event is over I_RST area then turn off and reset
case I_RST:
if (Window1.Get_mcupwr () && pic_reset (- 1))//if powered
{
Window1.Set_mcupwr (0);
Window1.Set_mcurst (1);
}
p_RST = 0;
output_ids[O_RST]- >update = 1;
break;
//if event is over I_D0 area then activate button (state=0)
case I_BD0:
p_BT1 = 0;
output_ids[O_BD0]- >update = 1;
break;
//if event is over I_D1 area then toggle switch state
case I_SD1:
p_BT2 ^= 1;
output_ids[O_SD1]- >update = 1;
break;
case I_POT1:
{
active = 1;
pot1 = (x - input[i].x1)*2.77;
if (pot1 > 199)pot1 = 199;
output_ids[O_POT1]- >update = 1;
}
break;
}
}
}
}
//Event on the board
void
cboard_x::EvMouseMove(uint button, uint x, uint y, uint state)
{
int i;
for (i = 0; i < inputc; i++)
{
switch (input[i].id)
{
case I_POT1:
if (((input[i].x1 <= x)&&(input[i].x2 >= x))&&((input[i].y1 <= y)&&(input[i].y2 >= y)))
{
if (active)
{
pot1 = (x - input[i].x1)*2.77;
if (pot1 > 199)pot1 = 199;
output_ids[O_POT1]- >update = 1;
}
}
break;
}
}
}
//Event on the board
void
cboard_x::EvKeyRelease(uint key, uint mask)
{
//if keyboard key 1 is pressed then deactivate button (state=1)
if (key == '1')
{
p_BT1 = 1;
output_ids[O_BD0]- >update = 1;
}
}
```
--------------------------------
### XC8 test program for the new PICSimLab board
Source: https://lcgamboa.github.io/picsimlab_docs/stable/FinalResult.html
Sample program to test the new board, written for the XC8 compiler. It includes configuration and library headers, initializes ADC and serial, and in a loop reads an ADC value, controls LEDs based on switch inputs, and sends the value over serial.
```C
#include ;
#include "config_4550.h"
#include "adc.h"
#include "serial.h"
#include "itoa.h"
void main()
{
unsigned int val;
char buffer[10];
ADCON1=0x02;
TRISA=0xFF;
TRISB=0xFC;
TRISC=0xBF;
TRISD=0xFF;
TRISE=0x0F;
adc_init();
serial_init();
while(1)
{
val=adc_amostra(0);
if(PORTDbits.RD1)
{
if(val > 340)
PORTBbits.RB0=1;
else
PORTBbits.RB0=0;
if(val > 680)
PORTBbits.RB1=1;
else
PORTBbits.RB1=0;
}
else
{
if(PORTDbits.RD0)
{
PORTBbits.RB0=1;
PORTBbits.RB1=0;
}
else
{
PORTBbits.RB0=0;
PORTBbits.RB1=1;
}
}
serial_tx_str(itoa(val,buffer));
serial_tx_str("\r\n");
}
}
```