Visit the website of CupCarbon
www.cupcarbon.com
You unzip the file cupcarbon.zip
You will get the following files:
You execute directly the jar file cupcarbon.jar
If CupCarbons tarts normally, then you are lucky, you can continue to use it
Otherwise, it means you have a recent version of Java
CupCarbon works only with the version 8 (1.8.xxx)
Since we are using JavaFX platfrm, CupCarbon runs only with the Java 8 version.
Therefore, you may install the version 8 (JDK/JRE 1.8) of java in your system
To do that, visit the following web page: (Link)
https://www.oracle.com/java/technologies/downloads/#java8
To check the version of java installed in your system, you can use the command:
java -version
Verify that the version is 1.8.xxx
If the version is not 8 then depending on your system you should either change the current default version to 8 or to run CupCarbon using the complete path of the java 8. For example, for mac OS, go to the directory where the cupcarbon.jar is situated and write the following command:
/Library/Java/JavaVirtualMachines/jdk1.8xx.jdk/Contents/Home/bin/java -jar cupcarbon.jar
jdk1.8xx can by any version starting with 1.8.
You can install any version of Python you want.
To verify if Python is installed you can use the following command:
python -V
Python is completely independent from CupCarbon, once installed, you have to get the complete path of the execution file of Python.
For example in mac OS, it can be something like:
/Library/Frameworks/Python.framework/Versions/3.11/bin/python
This path must be added in CupCarbon, it will be used to execute Python Code in CupCarbon environment.
To add this path in CupCarbon, either when you run the simuation, it will ask you to add it or click in the following button in the toolbar and enter this path.
Now you can use CupCarbon, enjoy!
To interace with CupCarbon from your Python codes, you can send commands to CupCarbon and you can get commands from CupCarbon as well.
To send commands from your code Python to CupCarbon, use the command print of Python normally. The message of the print will be considered as a CupCarbon command. You need to flush each command to send it directly, otherwise, all the commands will be sent once at the end of the program. In this case you have to use the command:
sys.stdout.flush() after each print command
To use this command you need to import the library sys, as follows:
import sys
In a nutshell:
Any Python program communicating with CupCarbon has to import the library sys, to send the CupCarbon comands using the command print and to flush the message (send it to CupCarbon) using the command flush:
import sys
print("CupCarbon command")
sys.stdout.flush()
The different commands that you can send to CupCarbon are given as follows:
1. print
To print any message on the executing device, use the command print as follows:
print("print Hellow World!")
sys.stdout.flush()
2. mark/unmark
To mark or unmark the executing device, use the commande mark or unmark as follows:
print("mark")
sys.stdout.flush()
print("unmark")
sys.stdout.flush()
3. move
To move the executing device to a given GPS location, use the move command as follows:
print("move 50.002 21.344")
sys.stdout.flush()
4. To get any information about the executing device sugh as, its id, its name and its location, use the following commands:
print("getid")
sys.stdout.flush()
id = input()
print("getname")
sys.stdout.flush()
name = input()
print("getxy")
sys.stdout.flush()
location = input()
print("getx")
sys.stdout.flush()
x = input()
print("gety")
sys.stdout.flush()
y = input()
To create IoT Projects using the MQTT protocol, just install MQTT for Python. Many tutorials exists on the web. It is possible to use MQTT in different real devices (Android device, iOS, ESP32, Raspberry, ...) to communicate or to synchronize with CupCarbon devices.
You can install Mosquitto to use MQTT from the terminal of your system.
Many pages on the web can help to install MQTT for Python of for any other platform. You can visit:
https://www.emqx.com/en/blog/how-to-use-mqtt-in-python
Two samples (Pbulisher and Subscriber) are given in CupCarbon that can be used directly. Don't forget to set the value of the broker and the topics.