Archive

Archive for the ‘Uncategorized’ Category

using pyserial

March 7, 2016 1 comment
import sys
import glob
import serial
import time


def serial_ports():
    if sys.platform.startswith('win'):
        ports = ['COM%s' % (i + 1) for i in range(256)]
    elif sys.platform.startswith('linux') or sys.platform.startswith('cygwin'):
        # this excludes your current terminal "/dev/tty"
        ports = glob.glob('/dev/tty[A-Za-z]*')
    elif sys.platform.startswith('darwin'):
        ports = glob.glob('/dev/tty.*')
    else:
        raise EnvironmentError('Unsupported platform')

    result = []
    for port in ports:
        try:
            s = serial.Serial(port)
            s.close()
            result.append(port)
        except (OSError, serial.SerialException):
            pass
    return result


def process(p):
    ser = serial.Serial(port=p,
                        baudrate=9600,
                        parity=serial.PARITY_EVEN,
                        stopbits=serial.STOPBITS_TWO,
                        bytesize=serial.EIGHTBITS)

    for i in range(100):
        ser.write('A')
        time.sleep(0.1);

        out = ''
        while ser.inWaiting() > 0:
            out += ser.read(1)

        if out != '':
            print ">>" + out

    ser.close()


if __name__ == '__main__':
    port = (serial_ports())[0]
    process(port)
Categories: code, Uncategorized

USIM command and file

August 24, 2015 Leave a comment

ATR | atr
Reset | reset
Format | A6F0000000 | reset
Virginize | A601000001FF | reset

USIM
SELECT FILE | print “00 A4 00 04 02 3F00”
STATUS | print “80 F2 00 00 00”
READ BINARY | print “00 B0 00 00 00”
UPDATE BINARY | print “00 D6 00 00 00”
READ RECORD | print “00 B2 00 00 00”
UPDATE RECORD | print “00 DC 00 00 00”
SEARCH RECORD | print “00 A2 00 00 00”
INCREASE | print “80 32 00 00 00”
RETRIEVE DATA | print “80 CB 00 00 00”
SET DATA | print “80 DB 00 00 00”
VERIFY | print “00 20 00 00 00”
CHANGE PIN | print “00 24 00 00 00”
DISABLE PIN | print “00 26 00 00 00”
ENABLE PIN | print “00 28 00 00 00”
UNBLOCK PIN | print “00 2C 00 00 00”
DEACTIVATE FILE | print “00 04 00 00 00”
ACTIVATE FILE | print “00 44 00 00 00”
AUTHENTICATE | print “00 88 00 00 00”
GET CHALLENGE | print “00 84 00 00 00”
TERMINAL CAPABILITY | print “80 AA 00 00 00”
TERMINAL PROFILE | print “80 10 00 00 00”
ENVELOPE | print “80 C2 00 00 00”
FETCH | print “80 12 00 00 00”
TERMINAL RESPONSE | print “80 14 00 00 00”
MANAGE CHANNEL | print “00 70 00 00 00”
MANAGE SECURE CHANNEL | print “00 73 00 00 00”
TRANSACT DATA | print “00 75 00 00 00”
GET RESPONSE | print “00 C0 00 00 00”

EF DF
MF | print “3F00”
DFGSM | print “7F20”
DFTELECOM | print “7F10”
EFDIR | print “2F00”
EFPL | print “2F05”
EFARR | print “2F06”
EFICCID | print “2FE2”
EFARR | print “6F06”
EFADN | print “6F3A”
EFFDN | print “6F3B”
EFSMS | print “6F3C”
EFECCP | print “6F4F”
EFMSISDN | print “6F40”
EFSMSP | print “6F42”
EFSMSS | print “6F43”
EFLND | print “6F44”
EFSMSR | print “6F47”
EFSDN | print “6F49”
EFEXT1 | print “6F4A”
EFEXT2 | print “6F4B”
EFEXT3 | print “6F4C”
EFBDN | print “6F4D”
EFEXT4 | print “6F4E”
EFSUME | print “6F54”
EFICE_DN | print “6FE0”
EFICE_FF | print “6FE1”
DFGRAPHICS | print “5F50”
EFIMG | print “4F20”
EFIIDFn | print “4FXX”
DFPHONEBOOK | print “5F3A”
EFPBR | print “4F30”
EFIAP | print “4FXX”
EFADN | print “4FXX”
EFEXT1 | print “4FXX”
EFPBC | print “4FXX”
EFGRP | print “4FXX”
EFAAS | print “4FXX”
EFGAS | print “4FXX”
EFANR | print “4FXX”
EFSNE | print “4FXX”
EFCCP1 | print “4FXX”
EFUID | print “4FXX”
EFPSC | print “4F22”
EFCC | print “4F23”
EFPUID | print “4F24”
EFEMAIL | print “4FXX”
DFMULTIMEDIA | print “5F3B”
EFMML | print “4F47”
EFMMDF | print “4F48”
EFPseudo | print “4F41”
EFUPLMNWLAN | print “4F42”
EF0PLMNWLAN | print “4F43”
EFUSSIDL | print “4F44”
EFOSSIDL | print “4F45”
EFWRI | print “4F46”
EFHWSIDL | print “4F47”
EFWEHPLMNPI | print “4F48”
EFWHPI | print “4F49”
EFWLRPLMN | print “4F4A”
DFPHONEBOOK | print “5F3A”
DFGSM-ACCESS | print “5F3B”
DFMExE | print “5F3C”
DFSoLSA | print “5F70”
DFWLAN | print “5F40”
EFORPK | print “4F41”
EFSAI | print “4F30”
EFSLL | print “4F31”
EFMExE-ST | print “4F40”
EFARPK | print “4F42”
EFTPRK | print “4F43”
EFTKCDF | print “4FXX”
EFKc | print “4F20”
EFKcGPRS | print “4F52”
EFCPBCCH | print “4F63”
EFinvSCAN | print “4F64”
EFUID | print “4FXX”
EFPSC | print “4F22”
EFCC | print “4F23”
EFPUID | print “4F24”
EFPBR | print “4F30”
EFCCP1 | print “4FXX”
EFIAP | print “4FXX”
EFADN | print “4FXX”
EFEXT1 | print “4FXX”
EFPBC | print “4FXX”
EFGRP | print “4FXX”
EFAAS | print “4FXX”
EFGAS | print “4FXX”
EFANR | print “4FXX”
EFSNE | print “4FXX”
EFEMAIL | print “4FXX”
EFLI | print “6F05”
EFARR | print “6F06”
EFIMSI | print “6F07”
EFKeys | print “6F08”
EFKeysPS | print “6F09”
EFDCK | print “6F2C”
EFHPPLMN | print “6F31”
EFCNL | print “6F32”
EFACMmax | print “6F37”
EFUST | print “6F38”
EFACM | print “6F39”
EFFDN | print “6F3B”
EFSMS | print “6F3C”
EFGID1 | print “6F3E”
EFGID2 | print “6F3F”
EFMSISDN | print “6F40”
EFPUCT | print “6F41”
EFSMSP | print “6F42”
EFSMSS | print “6F43”
EFCBMI | print “6F45”
EFSPN | print “6F46”
EFSMSR | print “6F47”
EFCBMID | print “6F48”
EFSDN | print “6F49”
EFEXT2 | print “6F4B”
EFEXT3 | print “6F4C”
EFBDN | print “6F4D”
EFEXT5 | print “6F4E”
EFCBMIR | print “6F50”
EFEXT4 | print “6F55”
EFEST | print “6F56”
EFACL | print “6F57”
EFCMI | print “6F58”
EFSTART-HFN | print “6F5B”
EFTHRESHOLD | print “6F5C”
EFPLMNwAcT | print “6F60”
EFOPLMNwAcT | print “6F61”
EFHPLMNwAcT | print “6F62”
EFEHPLMN | print “6FD9”
EFPSLOCI | print “6F73”
EFACC | print “6F78”
EFFPLMN | print “6F7B”
EFLOCI | print “6F7E”
EFICI | print “6F80”
EFOCI | print “6F81”
EFICT | print “6F82”
EFOCT | print “6F83”
EFAD | print “6FAD”
EFeMLPP | print “6FB5”
EFAAeM | print “6FB6”
EFECC | print “6FB7”
EFHiddenkey | print “6FC3”
EFNETPAR | print “6FC4”
EFPNN | print “6FC5”
EFOPL | print “6FC6”
EFMBDN | print “6FC7”
EFEXT6 | print “6FC8”
EFMBI | print “6FC9”
EFMWIS | print “6FCA”
EFCFIS | print “6FCB”
EFEXT7 | print “6FCC”
EFSPDI | print “6FCD”
EFMMSN | print “6FCE”
EFEXT8 | print “6FCF”
EFMMSICP | print “6FD0”
EFMMSUP | print “6FD1”
EFMMSUCP | print “6FD2”
EFNIA | print “6FD3”
EFCCP2 | print “6F4F”
EFVGCS | print “6FB1”
EFVGCSS | print “6FB2”
EFVBS | print “6FB3”
EFVBSS | print “6FB4”
EFVGCSCA | print “6FD4”
EFVBSCA | print “6FD5”
EFGBAP | print “6FD6”
EFMSK | print “6FD7”
EFMUK | print “6FD8”
EFGBANL | print “6FDA”
EFEHPLMNPI | print “6FDB”
EFLRPLMNSI | print “6FDC”
EFNAFKCA | print “6FDD”
EFSPNI | print “6FDE”
EFPNNI | print “6FDF”
EFNCP-IP | print “6FE2”
EFEPSLOCI | print “6FE3”
EFEPSNSC | print “6FE4”
DFHNB | print “5F50”
EFACSGL | print “4F81”
EFCSGI | print “4F82”
EFHNBN | print “4F83”
ADF | print “7FAA”

Clear | clear

Categories: Uncategorized

array besar di c

May 5, 2013 Leave a comment

waktu itu mau coba alokasikan array di c, ukuran 500an kali 35000an.

langsung crash, hehehe. coba pake cara lain

bikin array of pointer dulu, terus masing2 baru deh dialokasikan pakai malloc.

ini contoh programnya.

 

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main()
{
int width=600, height=40000;
int* foo[width];
int i;
for(i=0;i<width;i++) {
foo[i]=malloc(sizeof(int)*height);
}

foo[width-1][height-1]=5;
printf(“%d\n”, foo[width-1][height-1]);

for(i=0;i<width;i++) {
free(foo[i]);
}

printf(“end\n”);
}

Categories: Uncategorized

Tutorial+pembuktian+rumus+luas+lingkaran

February 14, 2011 Leave a comment

video_player_embed_code_text

Categories: Uncategorized

Test Page

February 14, 2011 Leave a comment

Test description

Categories: Uncategorized

Running external command from java

October 22, 2009 Leave a comment
import java.io.*;

public class ExternalCommand
{
public static void main(String args[]) throws Exception
{
String line;
OutputStream stdin = null;
InputStream stderr = null;
InputStream stdout = null;

// launch EXE and grab stdin/stdout and stderr
Process process = Runtime.getRuntime ().exec ("bc");
stdin = process.getOutputStream ();
stderr = process.getErrorStream ();
stdout = process.getInputStream ();

// "write" the parms into stdin
line = "13*3" + "\n";
stdin.write(line.getBytes() );
stdin.flush();

stdin.close();

// clean up if any output in stdout
BufferedReader brCleanUp =
new BufferedReader (new InputStreamReader (stdout));
while ((line = brCleanUp.readLine ()) != null) {
System.out.println ("[Stdout] " + line);
}
brCleanUp.close();

// clean up if any output in stderr
brCleanUp =
new BufferedReader (new InputStreamReader (stderr));
while ((line = brCleanUp.readLine ()) != null) {
System.out.println ("[Stderr] " + line);
}
brCleanUp.close();

}
}

ref: http://www.rgagnon.com/javadetails/java-0014.html

Categories: Uncategorized