Have there ever been any plans for JUCE to support serial port communications? (Obviously including via USB like what Arduino does.)
Until that time, you could use the JUCE Serial Port Library hosted here: http://omohmproductions.com/?page_id=145. I use it specifically to talk to Arduinoās.
Thanks, Iāll take a look at that!
I successfully used the asio (asynchronous I/O) library for that. Asio is part of boost but also available as lightweight header-only standalone version
Hi,
Do you have an example as how you use this? Iām new to Juce and trying to understand how to implement this.
Any direction would be great.
Thanks
I just updated an older project of mine to work with the latest JUCE, and put it on github. Iāve also moved the serial port library to github as well⦠Itās an āexampleā of how to use the library, but I canāt comment on the code quality⦠lolā¦
Thank you.
In your cSerialPortListMonitor.cpp, line 39 you are referencing SerialPort::getSerialPortPaths()⦠however I can not see anywhere in the cSerialPortListMonitor.h file, importing ājuce_serialport.hā?
How do you have access to the serialPort?
I have added the juce_serialport folder to the JUCE modules folder, thinking it would be included with āā¦/JuceLibraryCode/JuceHeader.hā
I have added the header and cpp file to Projucer, then launched it and included ājuce_serialport.hā inside my file - states could not be found.
Or have I got it all wrong when adding / including external libraries?
If itās a JUCE module the header should be included in JuceHeader.h and the source files will automatically be getting compiled for you, no need to add anything other than the the juce module to the Projucer.
What @anthony-nicholls and @richie said!
Ok. Strange. I added the juce_serialport folder from your website, and placed it inside the Juce modules folder. Then added it inside of Projucer via āAdd a module from a specified folderā¦ā and this is the resulting error:
However, when I added the juce_serialport folder to my desktop and re-add the module, it works.
Is this a known issue? Or should I never add any modules to the Juce module folder?
Thatās it. I noticed that it does not work by adding any module to the JUCE module folder.
Instead you can simply create a folder for āuser modulesā which is linked into āGlobal Pathsā.
I canāt comment on the underlying juce module
mechanism, and whether or not 3rd party modules can be added to the JUCE modules folder, but it isnāt an issue specific to the serial port module. I put all of my 3rd party modules in a separate folder.
Did this solve your linking issue?
No it does not. I keep having the same linking error whether I add the module from the user module folder (global path) or from a separate folder. I just tried to write another simple project adding only the module and few lines to integrate serial port communications and it happens the same errors for all the functions Iām using.
I declare the related members in the header file as
MainComponent.h
class MainComponent : public Component
{
public:
ā¦
// Serial Ports
StringPairArray portList;
SerialPortConfig SPConfig {9600, 8, SerialPortConfig::SERIALPORT_PARITY_NONE, SerialPortConfig::STOPBITS_1, SerialPortConfig::FLOWCONTROL_NONE};
SerialPort* pSP;
SerialPortInputStream * pInputStream;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainComponent)
};
and as follows in the constructor :
MainComponent.cpp
MainComponent::MainComponent()
{
portList = SerialPort::getSerialPortPaths();
if (portList.size())
{
int numberOfPorts = portList.size();
for (int i=0; i<numberOfPorts; ++i) { // find the expected port to use
String name = portList.getAllValues()[i];
if (name == "/dev/tty.usbmodem143401")
{
pSP = new SerialPort(portList.getAllValues()[1],SerialPortConfig(9600, 8, SerialPortConfig::SERIALPORT_PARITY_NONE, SerialPortConfig::STOPBITS_1, SerialPortConfig::FLOWCONTROL_NONE)); // create the serial port
pInputStream = new SerialPortInputStream(pSP); // create stream for reading
pInputStream->setNotify(SerialPortInputStream::NOTIFY_ON_CHAR,'1');
}
ā¦
}
The whole code compiles well. But still linker error
Hi Chris,
Dear Chris,
Hope you doing good. iām trying to integrate this module into a juce project.
Following error happen. Can you help to check?
JNI DETECTED ERROR IN APPLICATION: JNI NewGlobalRef called with pending exception java.lang.ClassNotFoundException: Didnāt find class ācom.artiphon.juce_serial.UsbSerialHelperā on path: DexPathList[[zip file ā/data/app/com.juce.audioplaybackdemo-MUG7xSP70eHXPcmEBK7J5A==/base.apkā],nativeLibraryDirectories=[/data/app/com.juce.audioplaybackdemo-MUG7xSP70eHXPcmEBK7J5A==/lib/arm64, /data/app/com.juce.audioplaybackdemo-MUG7xSP70eHXPcmEBK7J5A==/base.apk!/lib/arm64-v8a, /system/lib64, /system/product/lib64]]
Thanks
Paiday
Hello everyone, Hi @cpr2323,
I often use this library for serial communication and it works great, however on Windows I keep getting memory leaks when closing the app, when Serial port is connected and used.
Does anyone have a simple code example with the lib ? Maybe @cpr2323, I read you have sent sample code.
Hereās what VS Code tells me about memory leaks when closing the app :
Detected memory leaks!
Dumping objects ā
{150166} normal block at 0x000001F31B82E3B0, 96 bytes long.
Data: < <7: 8 > 80 3C 37 3A F7 7F 00 00 38 07 00 00 00 00 00 00
{150161} normal block at 0x000001F31B7B5460, 35 bytes long.
Data: < > 00 00 00 00 CD CD CD CD 0C 00 00 00 00 00 00 00
Object dump complete.
It seems weird to me that the class name is not explicit, and not even the same each time, and never coherent.
Maybe Iām doing something wrong and I would like to compare.
Thank you very much for your help.
Titouan
Iām happy to take a look. Iāll double check my example code, and if you have a small example that exhibits this behavior, I can try that too. I fixed a bug recently (in Feb or March) so it would be good to know if your issue arose before,or after, that change
Sorry I missed your msg. Did you ever get this resolved? I didnāt do the Android implementation, but I check to see what is needed.
Iāve tried including the juce_serialport_master folder into modules by going projucer->modules->add a module from specific folder-> juce_serialport_master but it says this is not a valid module folder. Is this module still working? I need it like a diabetic needs insulin. My life depends on it.
Does JUCE not have a built in module for this?