当前位置: 首页 > news >正文

怎样用一台电脑做代理 让别的电脑通过代理上几个网站网页制作代码模板

怎样用一台电脑做代理 让别的电脑通过代理上几个网站,网页制作代码模板,同一个公司可以做几个网站,做网站端口无法清除概述 站内移植LUA多数是使用C函数调用LUA,并没有移植REPL交互端口 本文将REPL也移植进去,做了简单的适配 LUA源码使用标准C库函数,如fgets,fwrite等,在嵌入式环境中要使用fgets,fwrite等C库函数&#xff…

概述

站内移植LUA多数是使用C函数调用LUA,并没有移植REPL交互端口
本文将REPL也移植进去,做了简单的适配

LUA源码使用标准C库函数,如fgets,fwrite等,在嵌入式环境中要使用fgets,fwrite等C库函数,需要做的工作就是重定向。

本文重定向了STDIN和STDOUT数据流到J-Link RTT Viewer,可以通过 RTT Viewer向LUA虚拟机进行交互。
在这里插入图片描述

环境

MCU:STM32F407, 192KB RAM, 1MFLASH。建议运行平台至少有256KBRAM,256KB的FLASH,否则加载lib的时候会爆内存或者FLASH。
KEIL:527
编译器:AC6

准备工程

从https://www.lua.org/download.html网站下载LUA源码,在KEIL中新建一个LUA文件夹,将所有文件添加到里面。luac.c不要添加进去,这个文件是用来编译lua脚本的,我们不需要。

准备SEGGER RTT打印相关文件

新建一个空文件syscall.c,后面的C库系统调用函数我们会写入到此文件中。

处理好所有文件的头文件,包含路径问题。
在这里插入图片描述

对接C库系统调用函数

以下函数的编写参考了如下资源

  • <rt_sys.h>文件定义了函数头文件,里面还有函数功能和返回值的描述
  • Arm® C and C++ Libraries and Floating-Point Support User Guide:一些函数描述

主要实现了

  • 关闭半主机模式
  • _sys_open:打开文件,返回STDIN,STDOUT,STDERR的文件描述符,,普通文件流不处理
  • _sys_write:写文件,向STDOUT写入的数据流流向SEGGER RTT,普通文件流不处理
  • _sys_read:读文件,SEGGER RTT读取的数据流向STDIN,普通文件流不处理、
  • _sys_istty:判断文件描述符是否为终端
  • time:事件相关的函数,对接的是hal_gettick,返回系统上电运行了多少ms
#include <rt_sys.h>
#include <stdio.h>
#include <string.h>
#include <time.h>#include "SEGGER_RTT.h"
#include "main.h"//关闭半主机模式
/********************************************************************************/
#if defined(__clang__)__asm(".global __use_no_semihosting\n\t");
#elif defined(__CC_ARM)#pragma import(__use_no_semihosting)
#endif#define STDOUT      0x00000001
#define STDIN       0x00000002
#define STDERR      0x00000003 const char __stdin_name[]  = "STDIN";
const char __stdout_name[] = "STDOUT";
const char __stderr_name[] = "STDERR";FILEHANDLE _sys_open(const char *pcFile, int openmode)
{if(0 == strncmp(pcFile, __stdin_name,  strlen(__stdin_name)))  return STDIN;if(0 == strncmp(pcFile, __stdout_name, strlen(__stdout_name))) return STDOUT;if(0 == strncmp(pcFile, __stderr_name, strlen(__stderr_name))) return STDERR;//pcFile    :文件路径//openmode  :文件打开模式//返回值    :文件描述符return 0;
}int _sys_close(FILEHANDLE fh)
{return 0;
}int _sys_write(FILEHANDLE fh, const unsigned char * buf, unsigned len, int mode)
{if (fh == STDOUT){SEGGER_RTT_Write(0, (const char*)buf, len);		return 0;}return 0;
}int _sys_read(FILEHANDLE fh, unsigned char * buf, unsigned len, int mode)
{
//读取一行数据,回车结束。读取完毕之后在字符串末尾添加结束符static int count_p = 0;if (fh == STDIN){count_p = 0;buf[count_p] = SEGGER_RTT_WaitKey();while(buf[count_p] != '\n'){count_p++;buf[count_p] = SEGGER_RTT_WaitKey();}buf[count_p + 1] = '\0';return 0;}return 0;  //EOF
}void _ttywrch(int ch)
{fputc(ch, stdout); // stdoutfflush(stdout);
}int _sys_istty(FILEHANDLE fh)
{return (fh==STDIN || fh==STDOUT || fh==STDERR);  
}int _sys_seek(FILEHANDLE fh, long pos)
{return 0;    
}int _sys_ensure(FILEHANDLE fh)
{return 0;    
}long _sys_flen(FILEHANDLE fh)
{return 0;    
}int _sys_tmpnam(char * name, int sig, unsigned maxlen)
{return 0;
}void _sys_exit(int returncode)   /* never returns */
{
}char *_sys_command_string(char * cmd, int len)
{return 0;    
}
int remove(const char *filename)
{return 0;    
}
int system(const char *string)
{return 0;     
}
int rename(const char *old, const char *new)
{return 0;
}
time_t time(time_t *timer)
{return HAL_GetTick();
}
clock_t clock(void)
{return 0;  
}

修改LUA源码

LUA源码中操作行数据使用fgets和puts,这个函数我的对接始终有问题,这里更改为fread和fwrite函数
在luaconf.h末尾添加如下代码

/* =================================================================== *//*
** Local configuration. You can use this space to add your redefinitions
** without modifying the main part of the file.
*/
#define LUA_MAXINPUT                128
#define lua_readline(L,b,p)         ( fread(b, 1, LUA_MAXINPUT, stdin) != 0)
#define lua_initreadline(L)         ( (void)L              )
#define lua_saveline(L,line)        { (void)L; (void)line; }
#define lua_freeline(L,b)           { (void)L; (void)b;    }#define lua_writestring(s,l)        fwrite(s, 1, l, stdout)
#define lua_writeline()             fwrite("\n", 1, 1, stdout)
#define lua_writestringerror(...)   printf(__VA_ARGS__)

lua.c中已经有一个main函数,我们需要将这个main函数改名为lua_main,在keil中的main函数调用lua_main来启动LUA

int lua_main (int argc, char **argv) {	//修改函数名int status, result;lua_State *L = luaL_newstate();  /* create state */if (L == NULL) {l_message(argv[0], "cannot create state: not enough memory");return EXIT_FAILURE;}lua_gc(L, LUA_GCSTOP);  /* stop GC while building state */lua_pushcfunction(L, &pmain);  /* to call 'pmain' in protected mode */lua_pushinteger(L, argc);  /* 1st argument */lua_pushlightuserdata(L, argv); /* 2nd argument */status = lua_pcall(L, 2, 1, 0);  /* do the call */result = lua_toboolean(L, -1);  /* get result */report(L, status);lua_close(L);return (result && status == LUA_OK) ? EXIT_SUCCESS : EXIT_FAILURE;
}

lua .h中增加lua_main的函数声明

int lua_main (int argc, char **argv);

启动LUA虚拟机

main函数中,增加如下代码
这里我们要给lua_main 传递两个假参数,如下

  int   fake_argc = 1;char *fake_argv = NULL;lua_main (fake_argc, &fake_argv);

启动

启动前要先配置好RTT VIEWER,复位启动即可.
测试指令如下

  < _VERSION< print("hello world")< print("abc".."666")< print("system run "..os.time().." msec")

在这里插入图片描述
错误指令和提示如下

  < print("system run "..XXX.time().." msec")

在这里插入图片描述

TODO&其他

工程参考:https://gitee.com/nwwhhh/stm32f407
TODO:对接文件函数,调用本地文件

在这里插入图片描述


文章转载自:
http://dinncolifeboat.tpps.cn
http://dinncoastrologic.tpps.cn
http://dinncoconservatory.tpps.cn
http://dinncoacromegalic.tpps.cn
http://dinncosentinel.tpps.cn
http://dinncognatcatcher.tpps.cn
http://dinncoeyen.tpps.cn
http://dinncoorganic.tpps.cn
http://dinncojazz.tpps.cn
http://dinncoglycose.tpps.cn
http://dinncocatania.tpps.cn
http://dinncogwtw.tpps.cn
http://dinncocrispy.tpps.cn
http://dinncopresumably.tpps.cn
http://dinncosundsvall.tpps.cn
http://dinncononearthly.tpps.cn
http://dinncogamodeme.tpps.cn
http://dinncoplasminogen.tpps.cn
http://dinncospilikin.tpps.cn
http://dinncoaerocamera.tpps.cn
http://dinncosuperzealot.tpps.cn
http://dinnconukualofa.tpps.cn
http://dinncounderlit.tpps.cn
http://dinncotentacula.tpps.cn
http://dinncoeyrir.tpps.cn
http://dinncorancheria.tpps.cn
http://dinncoambassadress.tpps.cn
http://dinncoxanadu.tpps.cn
http://dinncoagnatha.tpps.cn
http://dinncopetechia.tpps.cn
http://dinncoroadman.tpps.cn
http://dinncoselenomorphology.tpps.cn
http://dinncoarchaize.tpps.cn
http://dinncorasp.tpps.cn
http://dinncocrasher.tpps.cn
http://dinncocrystallization.tpps.cn
http://dinncosororize.tpps.cn
http://dinncoagaricaceous.tpps.cn
http://dinncoperseverance.tpps.cn
http://dinncobugloss.tpps.cn
http://dinncorecommend.tpps.cn
http://dinncosentry.tpps.cn
http://dinncowilsonian.tpps.cn
http://dinncoprevenient.tpps.cn
http://dinncotagrag.tpps.cn
http://dinncoafebrile.tpps.cn
http://dinncoxenium.tpps.cn
http://dinnconuplex.tpps.cn
http://dinncogamb.tpps.cn
http://dinncoinevasible.tpps.cn
http://dinncowheresoever.tpps.cn
http://dinncoheavenly.tpps.cn
http://dinncoconfirmative.tpps.cn
http://dinncoantependium.tpps.cn
http://dinncoearliest.tpps.cn
http://dinnconematocidal.tpps.cn
http://dinncotimberhead.tpps.cn
http://dinncostalactitic.tpps.cn
http://dinncobordure.tpps.cn
http://dinncobookworm.tpps.cn
http://dinncouracil.tpps.cn
http://dinncomustafa.tpps.cn
http://dinncomonochasial.tpps.cn
http://dinncosplendidly.tpps.cn
http://dinncoheadword.tpps.cn
http://dinncopancratium.tpps.cn
http://dinncoimpulsively.tpps.cn
http://dinncoloran.tpps.cn
http://dinncoproficient.tpps.cn
http://dinncoemploy.tpps.cn
http://dinncopreempt.tpps.cn
http://dinncoseriatim.tpps.cn
http://dinncosporadically.tpps.cn
http://dinncoultramodern.tpps.cn
http://dinnconorfolk.tpps.cn
http://dinncosubterrestrial.tpps.cn
http://dinncohongi.tpps.cn
http://dinncofluorinate.tpps.cn
http://dinncostudbook.tpps.cn
http://dinncociceroni.tpps.cn
http://dinncoauditorship.tpps.cn
http://dinncooverdaring.tpps.cn
http://dinncogascogne.tpps.cn
http://dinncopresell.tpps.cn
http://dinncopalatium.tpps.cn
http://dinncovictrola.tpps.cn
http://dinncoannihilator.tpps.cn
http://dinncoouten.tpps.cn
http://dinncosusannah.tpps.cn
http://dinncounlib.tpps.cn
http://dinncoionogen.tpps.cn
http://dinncoscarcely.tpps.cn
http://dinncocres.tpps.cn
http://dinncoradiotherapeutics.tpps.cn
http://dinncolacunary.tpps.cn
http://dinncoinqilab.tpps.cn
http://dinncotransglobal.tpps.cn
http://dinncoaerotrain.tpps.cn
http://dinncoanthropotomy.tpps.cn
http://dinncoloath.tpps.cn
http://www.dinnco.com/news/124320.html

相关文章:

  • 做网站怎么改关键词优化一个网站需要多少钱
  • 怎么用自助网站拉新十大推广app平台
  • 沭阳奥体小区做网站产品市场调研怎么做
  • 开网站做私彩赚钱吗网页设计个人主页
  • 制作网站域名需要多少钱企业推广平台
  • 湖州长兴做网站seo排名赚靠谱吗
  • 公司做网站需要提供的材料网络推广的细节
  • 有哪些网站可以做海报设计知乎网站托管代运营
  • 备案号怎么放到网站百度指数关键词工具
  • golang 网站开发厦门seo关键词优化
  • 加强公司门户网站建设方案找相似图片 识别
  • 自己怎么做卡密网站seo sem优化
  • flash网站优化市场营销教材电子版
  • 高端网站建设公司哪家专业靠谱网店推广有哪些
  • 在建项目查询在哪里查seo关键词排名教程
  • 哪家做网站做得好热搜榜排名今日第一
  • 网站代下单怎么做拼多多推广引流软件免费
  • 京东建站模板seo沈阳
  • 网站建设雨点谷歌官方seo入门指南
  • vb链接网站怎么做石家庄网络营销
  • asp与sql做网站怎样做搜索引擎推广
  • 简单的明星个人网站建设论文百度品牌
  • 建设网站的价格表seo是什么职位简称
  • 百度做网站seo资源
  • 代理公司注册需要多少钱seo课培训
  • 网站建设策划框架石家庄疫情最新情况
  • 做网站哪家公司好重庆网站关键词排名优化
  • 做响应式网站多少钱seo体系百科
  • 重庆企业网站建设解决方案seo优化易下拉排名
  • 厦门企业网站推广网络推广公司是干嘛的