Ambiera ForumDiscussions, Help and Support. |
|
[ 1 2 ] Page 1 of 2 |
|
|||||
|
Hi, I need to make CC communicate with an Arduino card using RS232 serial port. Any idea ? |
||||
|
You could use the "system" interface to call another exe which does the communication for you, maybe. |
||||
|
I just saw node.js allow serial port access. |
||||
|
I'm not very used to use Javascript. |
||||
|
If I put this library in the Html page (after or before ?) CC's one |
||||
|
will I be able to call it in Coppercube ? |
||||
|
Not sure if that will run in the browser, but node probably won't in CopperCube windows .exe target. |
||||
|
You talked about using system interface for launching and exe, ok. I must make communicate the CC .exe and an Arduino card using RS 232 port in bi-directionnal mode. I tried to use the .exe to receive data from the card via RS232 port and write these received data on disk in a text file. I use the CC's .exe to read this file every 50 ms. It works ... Strangely I have no access problems ... But I have such problem in the other direction : From CC to the .exe, using text file too. Sometime the .exe try to reset the text file for reading it while CC is writing in ... Avoiding simultaneous access promise to be complicated ... |
||||
|
One way to avoid simultaneous access could be to create another (empty) file called LOCK (or any other name) and then implement the following steps: for CC - CC creates the LOCK file; - CC writes in the shared text file; - at the end of the writing process, CC deletes the LOCK file; for the "exe in the middle" - if the LOCK file exists, the exe can not access the text file and waits until the LOCK file has been deleted; |
||||
|
thanck you. unfortunately CC is not able to do some fileexist or deletefile or renamefile. only read or write |
||||
|
Maybe Niko or someone who's is able to modify CC's source will put these functions in (fileexist, filerename, filedelete). |
||||
|
Good idea! Will do. |
||||
|
Ok Niko |
||||
|
Ok, just to give it a try ... Since CC can send commands to the DOS prompt, I used it as workaround. The downside are the flashes on the screen for opening and closing of the prompt. It's a simple implementation, I hope this can be useful anyway. I assume that all files are in the same folder of the CC.exe. --- Write ---
--- Read ---
You can download the CC file here: https://drive.google.com/file/d/... |
||||
|
Nice Idea too Damians ! :) I try using your first idea (semaphore/flags). The middle .exe receive data from arduino CC write a file containing data to transmit (f1.txt) and when it has finished it write a file called 'ok'.txt on the disk. When the middle .exe sees the "ok.txt" file it reads f1.txt and delete ok.txt after. It seems to work. In the inverse transmission (Arduino to CC) the middle .exe receives data from arduino using RS232, writes it immediately into f2.txt if it has changed. CC read f2.txt every 20 ms and strangely I never had any read error from CC but the problem is not solved. How CC could be aware, without using a "fileexist" function (CC doesn't allow this), of the existence of a file on the disk ? (I would like to use the same flag/semaphore system like "CC reads a file if it sees ok.txt on the disk). |
[ 1 2 ] Page 1 of 2 |
|