New c-style OOP scripting framework and IDE

ZHDX227
Posts: 16
Joined: Thu Oct 25, 2018 4:43 am

New c-style OOP scripting framework and IDE

Postby ZHDX227 » Thu Nov 22, 2018 6:20 am

Hi everyone,

I am making a script solution to implement my ideas into chip easier.
mcs_02.png
mcs_02.png (194.32 KiB) Viewed 12356 times
Key features:

1 - Good IDE
Usb connect and play, Click and run script in 1 second , Save as startup script without PC connected.
CPU/Memory/Network status monitoring, Log output , Fixed position Text/Image output.

2 - Powerful scripting language
C-Style , weak/strong type , closure , class/function/delegate , class inside function , function inside class
virtual/override OOP , property getter/setter, JSON , Binary serialization
try/catch/finally , exception stacktrace and line number ,
Eval script string, Asynchronize programming, Multi-Task programming , foreach keyword for list/dict
Work with custom c++ code, pre-compile into C++ code for obfuscation and better performance .
Object destruction callback , Object attached dictionary , .... etc ....

3 - Memory (WROOM):
Spend 55K memory when startup, and 260K free for play ideas.
Spend 38K for WIFI+LWIP , 220K free for client/server.
Spend 30-40K for Http library , 180K free for fast Http client/server scripting

4 - IO:
GPIO/PWM/SPI , tested 320x240 TFT as 16 FPS , need more time for others

5 - Network Performance
Big Buffer: WROOM 900KB/s , WROVER 1.5MB/s
(Depend on the buffer setting in menuconfig)
Small Buffer: about 18 socket connection + 330 http keep-alive requests per second .
Tested 12 connections in WROOM

------

Now It works and stable, just still need 3-4 months to finish more libraries.

Will be available at 2019

ZHDX227
Posts: 16
Joined: Thu Oct 25, 2018 4:43 am

Re: New c-style OOP scripting framework and IDE

Postby ZHDX227 » Thu Nov 22, 2018 6:27 am

The script language , code syntax samples,

24 line class to implement a protocol
which help me to control the gpio 26 LED from remote side

Code: Select all

class MCSCloudClient
{
    var url,key,pwd,dev,sid,headers;
    function MCSCloudClient(argurl, argkey, argpwd, argdev, argheaders) {
		url = argurl;key = argkey;pwd = argpwd;dev = argdev;headers=argheaders;
	}
    function SendRequestTask(cmd, args) {
		var ht=Http.Post(url,headers,Object.Stringify({ cmd: cmd, args: args, sid: sid, key: key, pwd: pwd, dev: dev }));
		var obj=ht.ReadJsonObject();
		if(obj.error)throw("error "+obj.error+" : "+obj.result);
		return obj.result;
	}
	function Send() {
		return SendRequestTask("Send", $arguments);
	}
	function Read() {
		return SendRequestTask("Read", []);
	}
	function ConnectPeer(group) {
		var peer = new MCSCloudClient(url, key, pwd, dev,headers);
		peer.sid = peer.SendRequestTask("Peer", [group]);
		return peer;
	}
}


var mcc = new MCSCloudClient("http://192.168.1.77:88/test/CloudHandler.ashx", "myapikey", "myapipwd", "mydevice");

var peer = mcc.ConnectPeer("group1");

MCS.Log("DONE"+peer.sid);

Gpio out26=Gpio.Out(26);

while(true)
{
    var arr = peer.Read();
    foreach(var obj in arr)
    {
        if(obj[0]=="led-1")
        {
            out26.SetLevel(1);
        }
        if(obj[0]=="led-0")
        {
            out26.SetLevel(0);
        }
    }
}
100 lines code to show MJpeg stream into TFT monitor

Code: Select all

var eachrow=24;
var spi=Spi.Master("hspi",80,320*2*eachrow, 14 , 13 , 12 , 15 , 21 );

var rst=Gpio.Out(18);

rst.SetLevel(0);
delay(100);
rst.SetLevel(1);
delay(100);

var ili_init_cmds=[[207,[0,131,48],3],[237,[100,3,18,129],4],[232,[133,1,121],3],[203,[57,44,0,52,2],5],[247,[32],1],[234,[0,0],2],[192,[38],1],[193,[17],1],[197,[53,62],2],[199,[190],1],[54,[40],1],[58,[85],1],[177,[0,27],2],[242,[8],1],[38,[1],1],[224,[31,26,24,10,15,6,69,135,50,10,7,2,7,5,0],15],[225,[0,37,39,5,16,9,58,120,77,5,24,13,56,58,31],15],[42,[0,0,0,239],4],[43,[0,0,1,63],4],[44,[0],0],[183,[7],1],[182,[10,130,39,0],4],[17,[0],128],[41,[0],128]];

foreach(var item in ili_init_cmds)
{
    var buff=Buffer.Create(16,"DMA");
    foreach(var b in item[1])buff.WriteByte(b);
    spi.SendByte(item[0]);
    spi.SendBuffer(buff,1);
    if(item[2]>=128)delay(100);
}

function makebuff(v1,v2)
{
    Buffer b=Buffer.Create(4);
    b.WriteByte(v1>>8);
    b.WriteByte(v1&255);
    b.WriteByte(v2>>8);
    b.WriteByte(v2&255);
    return b;
}
function ShowJpegToLCD(jpegbuff)
{
    Buffer bmpbuff=__jpegdecode(jpegbuff);

    for(var i=0;i<240;i+=eachrow)
    {
        spi.SendByte(42);//x

        spi.SendBuffer(makebuff(0,320),1);
        
        spi.SendByte(43);//y
        
        spi.SendBuffer(makebuff(i,eachrow+i),1);
        
        spi.SendByte(44);//write
        
        spi.SendBuffer(bmpbuff.Subbuf(i*320*2,320*2*eachrow),1);
    }
    
}

var url="http://192.168.1.77:8081/";

var ht=Http.Get(url);

MCS.Log("connected.")

var buff;
var bline="--"+ht._boundary;

for(var t=0;;t++)
{
    var data=ht.Read();
	
	if(!buff)buff=data;
	else buff.Append(data);
    
	var spos=buff.Length-data.Length-bline.Length-4;
	var pos=buff.ToString().IndexOf(bline,spos>0?spos:0);
	if(pos==-1)
		continue;
	
	if(pos>0)//not first
	{
		var crlfpos=buff.IndexOfDoubleCrlf();
		if(crlfpos!=-1&&crlfpos<pos)
		{
			var headers=buff.Subbuf(0,crlfpos);
			var frame=buff.Subbuf(crlfpos+4,pos-crlfpos-4-2);//remove \r\n before next boundary
			ShowJpegToLCD(frame);
		}
	}
	
	var delsize=pos+bline.Length+2;
	if(buff.Length>=delsize)
	{
	    buff.SelfRemoveLeft(delsize);
	}
	else
	{
	    ht.Read(delsize-buff.Length);
	    buff=null;
	}
}

ZHDX227
Posts: 16
Joined: Thu Oct 25, 2018 4:43 am

Re: New c-style OOP scripting framework and IDE

Postby ZHDX227 » Mon Dec 10, 2018 3:25 am

Demo of the IDE Button idea

--

Recent update : optimized memory usage.
Now it support 16 active TCP concurrent connections and read or write small pieces 1000+ times per second.

--

The IDE helps to monitor the status of the chip

It's very helpful for the prototype of a product , or just test the pin-connection ,

Or a good peer debugger when connect another chip with UART/SPI/I2C/UDP/TCP etc .
Attachments
script_ide_2.png
script_ide_2.png (138.54 KiB) Viewed 12206 times

ZHDX227
Posts: 16
Joined: Thu Oct 25, 2018 4:43 am

Re: New c-style OOP scripting framework and IDE

Postby ZHDX227 » Mon Feb 25, 2019 10:10 am

Now support

ESP32
STM32
RaspberryPI
Windows C++ Emulator
.Net C++ CLI Emulator
Attachments
IDE_emulator.png
IDE_emulator.png (82.45 KiB) Viewed 11826 times

username
Posts: 528
Joined: Thu May 03, 2018 1:18 pm

Re: New c-style OOP scripting framework and IDE

Postby username » Fri Mar 29, 2019 6:06 pm

is there a version in English ?

Xavi92
Posts: 45
Joined: Thu Mar 28, 2019 2:26 pm

Re: New c-style OOP scripting framework and IDE

Postby Xavi92 » Mon Apr 29, 2019 7:48 pm

Mate, your job looks absolutely amazing. :shock: Where can I get this tool from?

Who is online

Users browsing this forum: No registered users and 41 guests