ホーム » Iwao の投稿 (ページ 21)

作者アーカイブ: Iwao

2025年5月
 123
45678910
11121314151617
18192021222324
25262728293031

カテゴリー

アーカイブ

ブログ統計情報

  • 113,008 アクセス


Python から CPP の呼出し – 2


予めデータ(vv_PLF)を作成して,必要に応じてファイルに出力するコード.

vv_PLF*	get_vv_PLF	(void)
{
	static	vv_PLF	G_PLF ;
	return	&G_PLF ;
	}
static	PyObject*	check_rd	(PyObject* self, PyObject* args)
{
	vv_PLF*	gvv_plf = get_vv_PLF() ;
	vv_PLF	vv_plf_ = ::Check_Revise_deg() ;
	*gvv_plf = vv_plf_ ;
	return	Py_None ;
	}
static	PyObject*	dump_svg	(PyObject* self, PyObject* args)
{
	vv_PLF*	gvv_plf = get_vv_PLF() ;
	::Dump_SVG(*gvv_plf) ;
	return	Py_None ;
	}
static	PyObject*	dump_ipl	(PyObject* self, PyObject* args)
{
	vv_PLF*	gvv_plf = get_vv_PLF() ;
	::Dump_ipl(*gvv_plf) ;
	return	Py_None ;
	}

Python から C++ の呼出し 複数のメソッドで共通な領域を使用する
Python 側では
* check_rd でデータを作成.
* dump_svg などでデータを出力.


3D データを読み込んで,指定されたファイル名(拡張子により形式を判断)で出力.

static	PyObject*	load	(PyObject* self, PyObject* args)
{
	const	char*	str_file = NULL ;
	if (!PyArg_ParseTuple(args,"s",&str_file))	{
		return	NULL ;
		}
	tstring	g3_file = str_file ;
	GonsA	gnsa = ::To_GonsA(g3_file.c_str()) ;
	set_GonsA(gnsa) ;
	return	Py_None;
	}
static	PyObject*	save	(PyObject* self, PyObject* args)
{
	const	char*	str_file = NULL ;
	if (!PyArg_ParseTuple(args,"s",&str_file))	{
		return	NULL ;
		}
	tstring	g3_file = str_file ;
	GonsA*	gnsa = ::get_GonsA() ;
	::GonsA_To(*gnsa,g3_file.c_str()) ;
	return	Py_None;
	}
static	PyObject*	gons_to	(PyObject* self, PyObject* args)
{
	const	char*	str_file = NULL ;
	if (!PyArg_ParseTuple(args,"s",&str_file))	{
		return	NULL ;
		}
	tstring	g3_file = str_file ;
	gons_to(g3_file.c_str()) ;
	return	Py_None;
	}

Python から C++ の呼出し 3D データの変換

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

Python から CPP の呼出し

雰囲気はつかめてきたので,以前作成した cpp を呼んでみることに…
実際の処理部分は C++ のコードだが,呼び出しは C の関数.
また引数もない状態なので,C 関数の system(“a.out”) と呼んでいるのと同様.

#include	"i_rd_dbg.hxx"
int _tmain(int argc, TCHAR* argv[])
{
	::Test_Revise_deg() ;
	return 0 ;
	}

#include	<Python.h>
#include	"i_rd_dbg.hxx"
#include	"messbar.cxx"

static	PyObject*	call_cpp(PyObject* self, PyObject* args)
{
	::Test_Revise_deg() ;
	return	Py_None ;
	}

static	PyMethodDef 	 	myMethods[] = {
	{	"_call_cpp_",	call_cpp,	METH_NOARGS,	"call cpp"		},
	{	NULL														},
	} ;

static	struct	PyModuleDef	call_mod = {
	PyModuleDef_HEAD_INIT,
	"call_mod",
	"call_cpp module",
	-1,
	myMethods
	} ;

PyMODINIT_FUNC	PyInit_call_mod(void)
{
	return	PyModule_Create(&call_mod) ;
	}

コンパイルして import まではできたが,メソッドをうまく呼び出せない.
>>> call_mod.call_cpp()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: module ‘call_mod’ has no attribute ‘call_cpp’
>>>
それで,メソッドを表示できないかと思い検索すると,
python でメソッドの一覧を取得する方法
他に dir(call_mod) もあった.

Iwao@AS5202T:/volume1/home/Iwao/test/test_py/call_c/call_cpp/T_Rvs_sc $ g++ rvs_sc_w.cpp -o call_mod.so  -fPIC -Wall -shared -I /volume1/.@plugins/AppCentral/python3/include/python3.7m/
Iwao@AS5202T:/volume1/home/Iwao/test/test_py/call_c/call_cpp/T_Rvs_sc $
Iwao@AS5202T:/volume1/home/Iwao/test/test_py/call_c/call_cpp/T_Rvs_sc $ python3
Python 3.7.0 (default, Aug 23 2018, 17:48:39)
[GCC 4.6.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import call_mod
>>> call_mod.call_cpp
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'call_mod' has no attribute 'call_cpp'
>>> call_mod.call_cpp()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'call_mod' has no attribute 'call_cpp'
>>> obj = call_mod
>>> import inspect
>>> for m in inspect.getmembers(obj):
...     print(m)
...
('__doc__', 'call_cpp module')
('__file__', '/volume1/home/Iwao/test/test_py/call_c/call_cpp/T_Rvs_sc/call_mod.so')
('__loader__', <_frozen_importlib_external.ExtensionFileLoader object at 0x7f5a1a35ec50>)
('__name__', 'call_mod')
('__package__', '')
('__spec__', ModuleSpec(name='call_mod', loader=<_frozen_importlib_external.ExtensionFileLoader object at 0x7f5a1a35ec50>, origin='/volume1/home/Iwao/test/test_py/call_c/call_cpp/T_Rvs_sc/call_mod.so'))
('_call_cpp_', <built-in function _call_cpp_>)
>>> call_mod._call_cpp_()
>>>

Python から cpp の呼出し メソッドの表示

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

ASUSTOR NAS に SSH 接続できない

AS5202T に SSH 接続 しようとすると,次のメッセージが表示されて接続できなくなった.
ssh_exchange_identification: read: Connection reset

Microsoft Windows [Version 10.0.18362.959]
(c) 2019 Microsoft Corporation. All rights reserved.

C:\Users\Iwao>ssh -l Iwao 192.168.1.75
ssh_exchange_identification: read: Connection reset

C:\Users\Iwao>ssh -l Iwao as5202t
Password:
Iwao@AS5202T:/volume1/home/Iwao $ exit
Connection to as5202t closed.

C:\Users\Iwao>ssh -l Iwao 192.168.1.75
Password:
Iwao@AS5202T:/volume1/home/Iwao $ exit
Connection to 192.168.1.75 closed.

C:\Users\Iwao>ssh -l Iwao 192.168.1.75
Password:
Password:
Password:
Iwao@192.168.1.75's password:
Connection closed by 192.168.1.75 port 22

C:\Users\Iwao>ssh -l Iwao 192.168.1.75
ssh_exchange_identification: read: Connection reset

C:\Users\Iwao> 

AS5202T に SSH 接続できなくなった


対応方法:
ADM に入って「設定」-「ADMディフェンダー」の「自動ブラックリスト」で「削除」する.
ADM 「設定」-「ADMディフェンダー」
スマートフォンの「AiMaster」では「オンラインユーザー」-「ブラックリスト」から.
AiMaster 「オンラインユーザー」-「ブラックリスト」

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

WinFile.exe v10.1.4.0

Win10 環境で 2019/05 から使っている WinFile
最近よく操作する「ファイル」-「リネーム」がかなりの確率でダウンする(エラーなどは表示されず抜ける).


ダウンロード先を見てみると新しいものがあった.
https://github.com/Microsoft/winfile/releases
WinFile.exe v10.1.4.0


「リネーム」でダウンするのは相変わらず.

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

Python から C の呼出し

C のコードを Python から呼出せないかと…
Python のドキュメントとしては次の所にある
C や C++ による Python の拡張

Win10      C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\include\Python.h
debian10   /usr/include/python3.7/Python.h
AS5202T    /volume1/.@plugins/AppCentral/python3/include/python3.7m/Python.h

Iwao@AS5202T:/volume1/.@plugins/AppCentral/python3/include/python3.7m $ find / -name Python.h
/volume1/.@plugins/AppCentral/linux-center/containers/debian10/rootfs/usr/include/python2.7/Python.h
/volume1/.@plugins/AppCentral/linux-center/containers/debian10/rootfs/usr/include/python3.7m/Python.h
/volume1/.@plugins/AppCentral/python/include/python2.7/Python.h
/volume1/.@plugins/AppCentral/python3/include/python3.7m/Python.h

検索 して見つけたもの.
https://www.fsi-embedded.jp/kumico/columns/?cat=python
https://qiita.com/donkonishi/items/b7825b34d0711e336c61
https://www.quark.kj.yamagata-u.ac.jp/~hiroki/python/?id=19
http://owa.as.wakwak.ne.jp/zope/docs/Python/BindingC/
https://cpp-learning.com/?s=”Python+C+API”


Iwao@AS5202T:/volume1/home/Iwao/test/test_py/call_c/hello/bak $ cat hellWrap.c
#include <Python.h>
extern int add(int, int);
extern void out(const char*, const char*);

PyObject* hello_add(PyObject* self, PyObject* args)
{
    int x, y, g;

    if (!PyArg_ParseTuple(args, "ii", &x, &y))
        return NULL;
    g = add(x, y);
    return Py_BuildValue("i", g);
}

PyObject* hello_out(PyObject* self, PyObject* args, PyObject* kw)
{
    const char* adrs = NULL;
    const char* name = NULL;
    static char* argnames[] = {"adrs", "name", NULL};

    if (!PyArg_ParseTupleAndKeywords(args, kw, "|ss",
            argnames, &adrs, &name))
        return NULL;
    out(adrs, name);
    return Py_BuildValue("");
}

static PyMethodDef hellomethods[] = {
    {"add", hello_add, METH_VARARGS},
    {"out", hello_out, METH_VARARGS | METH_KEYWORDS},
    {NULL}
};

void initchello(){
  Py_InitModule("hello", hellomethods);
}

Iwao@AS5202T:/volume1/home/Iwao/test/test_py/call_c/hello/bak $ gcc -fPIC -Wall -c -o hellWrap.o hellWrap.c -I /volume1/.@plugins/AppCentral/python/include/python2.7/
hellWrap.c:30:13: warning: initialization from incompatible pointer type [-Wincompatible-pointer-types]
     {"out", hello_out, METH_VARARGS | METH_KEYWORDS},
             ^~~~~~~~~
hellWrap.c:30:13: note: (near initialization for 'hellomethods[1].ml_meth')
Iwao@AS5202T:/volume1/home/Iwao/test/test_py/call_c/hello/bak $ gcc -fPIC -Wall -c -o hellWrap.o hellWrap.c -I /volume1/.@plugins/AppCentral/python/include/python2.7/
Iwao@AS5202T:/volume1/home/Iwao/test/test_py/call_c/hello/bak $   

Python から C の呼出し ラッパー
PyMethodDef の所でエラーとなっていていろいろと探すと,型を指定しているものがあり,それを指定.
https://bty.sakura.ne.jp/wp/archives/83

static PyMethodDef hellomethods[] = {
    {"add", (PyCFunction)hello_add, METH_VARARGS},
    {"out", (PyCFunction)hello_out, METH_VARARGS | METH_KEYWORDS},
    {NULL}
};

コンパイルは通る様になった.
Python から試そうとすると …

Iwao@AS5202T:/volume1/home/Iwao/test/test_py/call_c/hello $ gcc -fPIC -Wall -c -o helloWrap.o helloWrap.c -I /volume1/.@plugins/AppCentral/python/include/python2.7/
Iwao@AS5202T:/volume1/home/Iwao/test/test_py/call_c/hello $ gcc -fPIC -Wall -shared -o hellomodule.so hello.o helloWrap.o
Iwao@AS5202T:/volume1/home/Iwao/test/test_py/call_c/hello $ ll
total 44
drwxrwxrwx    3 Iwao     users       4.0K Jul 29 18:16 ./
drwxrwxrwx    5 Iwao     users       4.0K Jul 29 15:31 ../
drwxrwxrwx    2 Iwao     users       4.0K Jul 29 18:05 bak/
-rwxrwxrwx    1 Iwao     users        188 Jul 29 16:29 hello.c*
-rw-r--r--    1 Iwao     users       1.6K Jul 29 16:33 hello.o
-rwxrwxrwx    1 Iwao     users        910 Jul 29 16:32 helloWrap.BAK*
-rwxrwxrwx    1 Iwao     users        936 Jul 29 16:37 helloWrap.c*
-rw-r--r--    1 Iwao     users       3.1K Jul 29 18:16 helloWrap.o
-rwxr-xr-x    1 Iwao     users       8.3K Jul 29 18:16 hellomodule.so*
Iwao@AS5202T:/volume1/home/Iwao/test/test_py/call_c/hello $ python3
Python 3.7.0 (default, Aug 23 2018, 17:48:39)
[GCC 4.6.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import hello
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'hello'
>>> exit()
Iwao@AS5202T:/volume1/home/Iwao/test/test_py/call_c/hello $ python
Python 2.7.10 (default, Aug 19 2015, 09:18:54)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import hello
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: dynamic module does not define init function (inithello)
>>> exit()
Iwao@AS5202T:/volume1/home/Iwao/test/test_py/call_c/hello $   

Python から C の呼出し import でエラー
まだ何か違うみたい.
メッセージは inithello がないとなっているので helloWrap.c を見直すと…
void initchello() { … } となっている.
関数名を inithello に変更してビルドすると通った.
Python から C の呼出し


2020/07/30
今日は次の所を参考にさせてもらって…
https://cpp-learning.com/python_c_api_step1/

Iwao@AS5202T:/volume1/home/Iwao/test/test_py/call_c/py_hello $ gcc ph_hello.c -o mymodule.so -fPIC -Wall -shared -I /volume1/.@plugins/AppCentral/python3/include/python3.7m/
Iwao@AS5202T:/volume1/home/Iwao/test/test_py/call_c/py_hello $ python3
Python 3.7.0 (default, Aug 23 2018, 17:48:39)
[GCC 4.6.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import mymodule
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: dynamic module does not define module export function (PyInit_mymodule)
>>> import myModule
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'myModule'
>>>
Iwao@AS5202T:/volume1/home/Iwao/test/test_py/call_c/py_hello $ cp mymodule.so myModule.so
Iwao@AS5202T:/volume1/home/Iwao/test/test_py/call_c/py_hello $ ll
total 44
drwxrwxrwx    3 Iwao     users       4.0K Jul 30 16:49 ./
drwxrwxrwx    6 Iwao     users       4.0K Jul 30 14:59 ../
drwxrwxrwx    2 Iwao     users       4.0K Jul 30 16:48 bak/
-rwxr-xr-x    1 Iwao     users       8.1K Jul 30 16:49 myModule.so*
-rwxr-xr-x    1 Iwao     users       8.1K Jul 30 16:47 mymodule.so*
-rwxrwxrwx    1 Iwao     users        188 Jul 29 16:29 ph_hello.BAK*
-rwxrwxrwx    1 Iwao     users       1.3K Jul 30 16:27 ph_hello.c*
Iwao@AS5202T:/volume1/home/Iwao/test/test_py/call_c/py_hello $ python3
Python 3.7.0 (default, Aug 23 2018, 17:48:39)
[GCC 4.6.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import myModule
>>> myModule.helloworld
<built-in function helloworld>
>>> myModule.helloworld()
Hello World
>>>
>>>
>>>
>>>
Iwao@AS5202T:/volume1/home/Iwao/test/test_py/call_c/py_hello $

Python から C の呼出し  py_hello
コンパイル時の出力ファイル名 mymodule.so が間違っていた.正しくは myModule.so .


そこ には詳しく書かれているが,自分用にメモ.
PyMethodDef の “メソッド名” は Python 側での (モジュール名).(メソッド名) .
同様に PyModuleDef の “モジュール名” は import 時の名称..so の出力ファイル名も対応している必要がある?
文字列なので,異なっていてもコンパイル時のエラーにはならない.
実行時に見つからないなどのエラーとなる.


2020/07/31
続きの内容をやっていて…
https://cpp-learning.com/python_c_api_step2/
Python から C の呼出しでエラー
Fatal Python error: GC object already tracked
Python から C の呼出し  Py_DECREF をコメントに
c_list は Python 側で確保しているため Py_DECREF はうまくないのではないか?


https://jml.mish.work/python/call-c-python.html

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

Win10 IP 20H2 KB4568831

Win10 Insider Preview の環境に KB4568831 を入れてみた.
Win10 IP 20H2 KB4568831
あまり変わった部分がわからない…
Win10 IP 20H2 19042.421

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

CHttpFile アップロードの https 対応

以前作成した MFC によるアップロード の https 対応.
前回コードを書いた頃は https の環境が用意できなかったのでそのままと(http に)なっていた.


次の関数を呼び出して接続しているが,それぞれ引数が異なるものが用意されている.
CInternetSession::GetHttpConnection
CHttpConnection::OpenRequest
それらの引数に dwFlags があり,INTERNET_FLAG_SECURE が指定できる.
最初,両方の呼び出しに指定してみたが,CInternetSession::GetHttpConnection は指定しなくても通った.

	CInternetSession session(userAgent.c_str()) ;
	CHttpConnection* pServer = NULL ;
	CHttpFile*       pFile = NULL ;
	{
	//	if (is_ssl) {
	//		pServer = session.GetHttpConnection(serverN.c_str(),INTERNET_FLAG_SECURE,nPort) ;
	//		}
	//	else {
			pServer = session.GetHttpConnection(serverN.c_str(),nPort) ;
	//		}
		if (pServer == NULL)		{	return	false ;		}
		}
	{
		if (is_ssl) {
			pFile = pServer->OpenRequest(CHttpConnection::HTTP_VERB_POST,php,NULL,1,NULL,_T("HTTP/1.1"),INTERNET_FLAG_SECURE) ;
			}
		else {
			pFile = pServer->OpenRequest(CHttpConnection::HTTP_VERB_POST,php) ;
			}
		if (pFile == NULL)		{	return	false ;		}
	//	...
		}

MFC を使用したアップロード  https post
UpFile.hxx


参考にさせてもらったのは次の所.
How to send HTTPS request using WinInet?
WinInet(MFC)を使ったhttpとhttps(自己証明書)
WinInet (MFC) の SSL通信 で 開発中に自己署名証明書を利用する場合のコード

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

アップロードがうまく機能しない?

個人的なメモです.


php と form でアップロードしていた所に,汎用のアップロードツール で行うとうまく機能しない.
http://ds116/Test/mics/mba_wgl/


原因は,php の post を受け取って $_FILES を処理している所.
$tempfile = $_FILES[‘fname’][‘tmp_name’] ;
<input type="file" name="fname" accept=".dat">
https://dev.mish.work/wordpress/2018/04/19/php-_files/
これとアップロードツールの C のコード ::Make_send_data で設定している名称が合っていない.


php の受け取る部分を修正して意図した動作になった.
アップロードがうまく機能しない?

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

Python 負のインデックス

次の所を読ませてもらっていて感じたことを…
けいしゅけのブログ薬局 情報館
https://keisyuke-blogyakkyoku.xyz/python-list-index
今私が習得するのにタイミングや更新サイクルが丁度良いので助かっている.


ASUSTOR NAS AS5202T に SSH 接続して Python を操作.

C:\Program Files\Microsoft Office\Office14>cd C:\Users\Iwao\AppData\Local\Temp

C:\Users\Iwao\AppData\Local\Temp>ssh -l Iwao -p 22 192.168.1.75
Password:
Iwao@AS5202T:/volume1/home/Iwao $ python
Python 2.7.10 (default, Aug 19 2015, 09:18:54)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> a=[0,1,2,3,4]
>>> print(a[0])
0
>>> print(a[4])
4
>>> print(a[5])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
IndexError: list index out of range
>>> print(a[-1])
4
>>> print(a[-4])
1
>>> print(a[-5])
0
>>> print(a[-6])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
IndexError: list index out of range
>>>  

Python 負のインデックス
似たようなことを C++ でやろうとすると次の様な感じ.
std::cout << a[a.size()-1] ;


この様な記述ができるからか,今まで負のインデックスの必要性は感じたことがなかった.
また配列の検索で該当するものがないと -1 を返す様なコードもよく書く.
インデックスを変数で持つ時は?
いろいろ考えると個人的にはあまり使わないのではないかと思う.
Python などをやればもっと有効な使い方が出てくるのか?

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

GLUT でのメニュー

GLUT を使用してのテストコードで,起動後データを切替える方法がないかと…
メニューの利用で何とかできるか?


glutCreateMenu などで検索したがわかりやすい情報が少なかった.
https://seesaawiki.jp/w/mikk_ni3_92/d/%b4%f0%cb%dc%ca%d418
https://www.jstage.jst.go.jp/article/itej/67/5/67_417/_pdf
http://opengl.jp/glut/section06.html


以前作成した雛型に対して追加.メニュー部分はほぼリンク先のコードのまま.
https://jml.mish.work/index.php/cpp/cb-glut.html

#include	"glut_cb.hxx"
#include	<iostream>

void	cb_menu	(int val)
{
	std::cout << "menu val=" << val << std::endl ;
	}

int	main(int argc, char* argv[])
{
	::glutInitWindowPosition(200,100) ;
	::glutInitWindowSize	(600,400) ;
	::glutInitDisplayMode	(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH) ;
	::glutInit           	(&argc,argv) ;
	::glutCreateWindow   	(argv[0]) ;
	::glutReshapeFunc    	(cb_resize) ;
	::glutDisplayFunc     	(cb_display) ;
	::glutKeyboardFunc    	(cb_keyboard) ;
	::glutMouseFunc      	(cs_mouse) ;
	{
		::glutCreateMenu(cb_menu) ;
		::glutAddMenuEntry("name 1",1) ;
		::glutAddMenuEntry("name 2",2) ;
		::glutAddMenuEntry("name 3",3) ;
		::glutAttachMenu(GLUT_RIGHT_BUTTON) ;
		}
	::cb_init            	() ;
	::glutMainLoop      	() ;
	return	0 ;
	}

GLUT メニュー
結局はこの方法ではなく,予めリスト化して キー入力 により切り替える方法に.

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

Debian 環境に pip のインストール

PyOpenGL を使おうとして pip コマンドを打つと,コマンドがない.
どうも pip が入っていないみたいで,次の様に入力してインストール.
sudo apt install python-pip
更に PyOpenGL のインストール.
pip install PyOpenGL
Debian 環境に PyOpenGL のインストール


pip3 のインストールは
sudo apt install python3-pip


C:\WINDOWS\System32>cd C:\Users\Iwao\AppData\Local\Temp

C:\Users\Iwao\AppData\Local\Temp>ssh -l admin -p 22 lxcdebian10
admin@lxcdebian10's password:
Linux lxcdebian10 4.14.x #1 SMP Wed May 13 00:37:48 CST 2020 x86_64

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Thu Jul  9 10:51:02 2020 from fe80::ed6f:4991:21c9:1882%eth0
admin@lxcdebian10:~$ cat /usr/bin/pip
#!/usr/bin/python
# GENERATED BY DEBIAN

import sys

# Run the main entry point, similarly to how setuptools does it, but because
# we didn't install the actual entry point from setup.py, don't use the
# pkg_resources API.
from pip._internal import main
if __name__ == '__main__':
    sys.exit(main())
admin@lxcdebian10:~$ cat /usr/bin/pip3
#!/usr/bin/python3
# GENERATED BY DEBIAN

import sys

# Run the main entry point, similarly to how setuptools does it, but because
# we didn't install the actual entry point from setup.py, don't use the
# pkg_resources API.
from pip._internal import main
if __name__ == '__main__':
    sys.exit(main())
admin@lxcdebian10:~$  

Debian  cat pip , pip3

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

AS5202T Debian 10 に Image Magick

Raspberry Pi などと同様
sudo apt install imagemagick
Debian 環境に Image Magick のインストール
特に難しいことはない.
Debian 環境に Image Magic インストール後 display コマンド

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

AS5202T Debian 10 と VC

VC で ASUSTOR NAS Linux Center の Debian 10 Desktop を使用するための設定.


SSH 接続を可能にして gcc などをインストールしておく必要がある.
Linux development with C++ in Visual Studio


VC の「ツール」-「オプション」,「クロスプラットフォーム」-「接続マネージャー」-「追加」.
Debian 10 への接続の設定
SSH 接続する時の情報を設定する.
追加後「接続マネージャー」-「リモートヘッダー…」で「更新」するとエラー.
エラーが発生しました。Could not start the ‘rsync’ command on the remote host, please install it using your system package manager. Please see https://aka.ms/AA23jat for troubleshooting。詳細については、C:\Users\Iwao\AppData\Local\Temp\vslinux_header_update_log.txt を参照してください。トラブルシューティングを行うには、https://aka.ms/AA23jat をご覧ください。
エラーが発生しました。Could not start the 'rsync' command on the remote host, please install it using your system package manager.
この部分の対応方法はよくわからない.


VC のプロジェクトの設定を「lxcdebian10」に.
VC リモートビルドマシンを「lxcdebian10」に設定


これでビルドすれば大丈夫なはずだが,何故かエラー.
VC を再起動したり,プロジェクトを読み直したりしていたら通る様になった.
AS5202T Debuan 10 VC ビルド

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

AS5202T Debian 10

以前 インストールしてそのままになっていた環境.
その時わからなかったのが「タイムゾーン」の設定.
次の所を参考にさせてもらって設定.
Debian 10 busterをインストールして最初に行う設定と確認 10項目
Linux Center Debian 10 タイムゾーンの設定


共通のソースなどを参照するために…
Linux から Windows 環境への接続
Linux Center Debian 10 mount
接続先は,最終的には変更する予定.

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

弦と矢と半径 – 11

JavaScript 版で Canvas を使用する様にしてみた.
弦と矢と半径 JavaScript Canvas
https://mish.myds.me/Test/blog/r_cs/b/

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

AS5202T に mono インストール

Synology NAS にもあるので気になっていた mono
以前 MonoDevelop をインストールして少しは試したことがある.
それで,どこまでのものとして入るかをやってみた.
AS5202T App Central Mono

Iwao@AS5202T:/volume1/home/Iwao/test/mono $ ls /usr/local/AppCentral/mono/bin/
al*                        gacutil2*                  mono-api-info*             nunit-console2*
al2*                       genxs*                     mono-boehm*                nunit-console4*
asp-state*                 httpcfg*                   mono-cil-strip*            pdb2mdb*
asp-state2*                ikdasm*                    mono-configuration-crypto* pedump*
asp-state4*                ilasm*                     mono-find-provides*        permview*
caspol*                    illinkanalyzer*            mono-find-requires*        peverify*
cccheck*                   installvst*                mono-gdb.py                resgen*
ccrewrite*                 lc*                        mono-heapviz*              resgen2*
cert-sync*                 macpack*                   mono-package-runtime*      secutil*
cert2spc*                  makecert*                  mono-service*              setreg*
certmgr*                   mconfig*                   mono-service2*             sgen*
chktrust*                  mcs*                       mono-sgen*                 sgen-grep-binprot*
crlupdate*                 mdassembler*               mono-sgen-gdb.py           signcode*
csc*                       mdbrebase*                 mono-shlib-cop*            sn*
csc-dim*                   mdoc*                      mono-symbolicate*          soapsuds*
csharp*                    mdoc-assemble*             mono-test-install*         sqlmetal*
csi*                       mdoc-export-html*          mono-xmltool*              sqlsharp*
dbsessmgr*                 mdoc-export-msxdoc*        monodis*                   svcutil*
dbsessmgr2*                mdoc-update*               monodocer*                 vbc*
dbsessmgr4*                mdoc-validate*             monodocs2html*             wsdl*
disco*                     mdvalidater*               monodocs2slashdoc*         wsdl2*
dmcs*                      mkbundle*                  monograph*                 xbuild*
dtd2rng*                   mod*                       monolinker*                xsd*
dtd2xsd*                   mod-mono-server*           monop*                     xsp*
fastcgi-mono-server*       mod-mono-server2*          monop2*                    xsp2*
fastcgi-mono-server2*      mod-mono-server4*          mozroots*                  xsp4*
fastcgi-mono-server4*      mono@                      mprof-report*
gacutil*                   mono-api-html*             nunit-console*
Iwao@AS5202T:/volume1/home/Iwao/test/mono $                      

AS5202T AppCentral mono bin
mono 使い方」で検索.
mcs test.cs でコンパイル,mono test.exe で実行できるみたい.


2020/06/24
phpinfo() を見てみると mod_mono が読み込まれている.
AS5202T phpinfo() apache2handler mod_mono


mcs で出来上がった exe は Windows のコマンドプロンプトで実行できる.
Mono 環境でできた exe を実行

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

弦と矢と半径 – 10

JavaScript 数値入力で更新.

	<body>

<pre>
c : <input  type='number'  id='in__c'  value='8'  style='width:100px;'  step='any' /> <span  id='out_c'> </span>  <br />
s : <input  type='number'  id='in__s'  value='2'  style='width:100px;'  step='any' /> <span  id='out_s'> </span>  <br />
r : <input  type='number'  id='in__r'  value='5'  style='width:100px;'  step='any' /> <span  id='out_r'> </span>  <br />
</pre>
		<img	src='r_cs.png'	width='300px'>

		<script>

			function	r_cs	(c , s)		{	return	(        ( c*c )  / ( 8*s )  +  s/2 ) ;		}
			function	s_rc	(r , c)		{	return	( r-Math.sqrt(r*r - (c/2)*(c/2) )   ) ;		}
			function	c_rs	(r , s)		{	return	(   Math.sqrt(r*r - (r-s)*(r-s) )*2 ) ;		}

			function	f_c_rs	() {
				var	oc = document.querySelector("#out_c") ;
				var	os = document.querySelector("#out_s") ;
				var	or = document.querySelector("#out_r") ;
				var	ic = document.querySelector("#in__c") ;
				var	is = document.querySelector("#in__s") ;
				var	ir = document.querySelector("#in__r") ;
				var	fc = parseFloat(ic.value) ;
				var	fs = parseFloat(is.value) ;
				var	fr = parseFloat(ir.value) ;
				oc.textContent = "" ;
				os.textContent = "" ;
				or.textContent = "" ;
				os.textContent = s_rc(fr,fc) ;
				or.textContent = r_cs(fc,fs) ;
				}
		//	...
			{
				var	ec = document.getElementById("in__c") ;
				var	es = document.getElementById("in__s") ;
				var	er = document.getElementById("in__r") ;
				ec.addEventListener("keyup",f_c_rs, false) ;
				es.addEventListener("keyup",f_s_rc, false) ;
				er.addEventListener("keyup",f_r_cs, false) ;
				}

			</script>

		</body>

弦と矢と半径 JavaScript 版
https://mish.myds.me/…/r_cs/a/

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

弦と矢と半径 – 9

JavaScript で.

<body>
	c : <input	type='number'	id='in__c'	value='80.0'	size='10'	step='any'	/><input	type='submit'	value='c_rs'	id='c_rs'	/>	<span	id='out_c'> </span>	<br />
	s : <input	type='number'	id='in__s'	value='20.0'	size='10'	step='any'	/><input	type='submit'	value='s_rc'	id='s_rc'	/>	<span	id='out_s'> </span>	<br />
	r : <input	type='number'	id='in__r'	value='50.0'	size='10'	step='any'	/><input	type='submit'	value='r_cs'	id='r_cs'	/>	<span	id='out_r'> </span>	<br />
	<img	src='r_cs.png'	width='300px'>

	<script>
		function	r_cs	(c , s)		{	return	(        ( c*c )  / ( 8*s )  +  s/2 ) ;		}
		function	s_rc	(r , c)		{	return	( r-Math.sqrt(r*r - (c/2)*(c/2) )   ) ;		}
		function	c_rs	(r , s)		{	return	(   Math.sqrt(r*r - (r-s)*(r-s) )*2 ) ;		}

		function	f_c_rs	() {
			var	oc = document.querySelector("#out_c") ;
			var	os = document.querySelector("#out_s") ;
			var	or = document.querySelector("#out_r") ;
			var	ic = document.querySelector("#in__c") ;
			var	is = document.querySelector("#in__s") ;
			var	ir = document.querySelector("#in__r") ;
			var	fc = parseFloat(ic.value) ;
			var	fs = parseFloat(is.value) ;
			var	fr = parseFloat(ir.value) ;
			oc.textContent = "" ;
			os.textContent = "" ;
			or.textContent = "" ;
			oc.textContent = c_rs(fr,fs) ;
			}
		//	...
		{
			var	ec = document.getElementById("c_rs") ;
			var	es = document.getElementById("s_rc") ;
			var	er = document.getElementById("r_cs") ;
			ec.addEventListener("click",f_c_rs, false) ;
			es.addEventListener("click",f_s_rc, false) ;
			er.addEventListener("click",f_r_cs, false) ;
			}
		</script>
	</body>

R S C JavaScript
https://mish.myds.me/…/r_cs/9/

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

弦と矢と半径 – 8

Python を使用しないで PHP のみで.

<?php
	function	r_cs	($c , $s)	{	return	(    ( $c*$c )  / ( 8 *$s )   +  $s/2 ) ;	}
	function	s_rc	($r , $c)	{	return	( $r-sqrt($r*$r - ($c/2)*($c/2) )     ) ;	}
	function	c_rs	($r , $s)	{	return	(    sqrt($r*$r - ($r-$s)*($r-$s) )*2 ) ;	}
	?>

PHP のみで実装
https://mish.myds.me/…/r_cs/8/

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

AS5202T VirtualBox – 2

AS5202T の CPU 温度を見るといつもより高い.
「プロセス」情報を見ると VirtualBox が消費している.
AS5202T の「プロセス」状態
VNC で接続すると TiWorker.exe が CPU を食っている.
DevX  TiWorker.exe
丁度 Windows Update のタイミングみたい.
VNC 接続の仮想マシンは遅くて操作できないが,接続しているクライアントからソースなどは見える.
TiWorker が CPU を食っている
前回 の様なネットワークが途切れる状態にはまだなっていない.


「リモートデスクトップ」であれば仮想マシンも操作できた.
落ち着くまでそのままにしておくしかなさそう.


その後「再起動」待ちになっていたので仮想マシンを再起動.
また止まったような表示.
Windows Update の再起動で,止まったような状態?
CPU は食っているのでこのまま様子見.


2020/06/11
そのまま変わらないので,仮想マシンの「電源オフ」.
PC の VirtualBox で再起動.
2020/06 Windows Update
Windows Update での再起動がうまく動作しないのか?


AS5202T VirtualBox の仮想マシンとして起動した時,いつもより時間がかかることがある.
また,ネットワークがうまく接続されていないこともあり.
安定するまで何度か再起動の必要があるのかもしれない.
起動時止まった様に見えても 30 分程度はそのままにして様子を見た方が良さそう.
仮想マシンの CPU や HDD などのリソースへのアクセス状況が見えると良いのに…

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.