보물창고/Programming2015.11.11 23:00





해결 GPIO.setmode(GPIO.BOARD) AttributeError: 'module' object has no attribute 'setmode'



raspberry pi에서 RFID-RC522를 이용한 카드인식 시스템을 만들고 있었는데요

setmode에러가나서 한참을 고생하다 구글링을 통해 해결했습니다






구글 검색어
GPIO.setmode(GPIO.BOARD) AttributeError: 'module' object has no attribute 'setmode'

참고한 내용





출력된 에러

 

$sudo python Dump.py
Traceback (most recent call last):
File "Dump.py", line 21, in <module>
MIFAREReader = MFRC522.MFRC522()
File "/home/imcloud/download/MFRC522-python/MFRC522.py", line 112, in __init__
GPIO.setmode(GPIO.BOARD)
AttributeError: 'module' object has no attribute 'setmode'






해결 방법
sudo easy_install -U RPi.GPIO 이 명령어를 실행해서 RPI.GPIO를 설치합니다


$sudo easy_install -U RPi.GPIO
Searching for RPi.GPIO
Reading http://pypi.python.org/simple/RPi.GPIO/
Best match: RPi.GPIO 0.5.11
Downloading https://pypi.python.org/packages/source/R/RPi.GPIO/RPi.GPIO-0.5.11.tar.gz#md5=9dc3dab6ce2b7ccb833a866efb392821
Processing RPi.GPIO-0.5.11.tar.gz
Running RPi.GPIO-0.5.11/setup.py -q bdist_egg --dist-dir /tmp/easy_install-IOIu1H/RPi.GPIO-0.5.11/egg-dist-tmp-yky5fe
zip_safe flag not set; analyzing archive contents...
Removing RPi.GPIO 0.1.0 from easy-install.pth file
Adding RPi.GPIO 0.5.11 to easy-install.pth file

Installed /usr/local/lib/python2.7/dist-packages/RPi.GPIO-0.5.11-py2.7-linux-armv6l.egg
Processing dependencies for RPi.GPIO

Finished processing dependencies for RPi.GPIO 






에러를 해결후 잘 동작함


$sudo python Read.py
Welcome to the MFRC522 data read example
Press Ctrl-C to stop.
Card detected
Card read UID: 23,101,85,197
Size: 8
Sector 8 [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
Card detected
Card read UID: 23,101,85,197
Size: 8
Sector 8 [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
Card detected
Card read UID: 23,101,85,197
Size: 8
Sector 8 [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
Card detected
Card read UID: 23,101,85,197
Size: 8
Sector 8 [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
Card detected
Card read UID: 23,101,85,197
Size: 8
Sector 8 [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
Card detected
Card read UID: 23,101,85,197
Size: 8
Sector 8 [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
Card detected
Card read UID: 23,101,85,197
Size: 8
Sector 8 [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

^CCtrl+C captured, ending read.

 




신고





Posted by 파란물
보물창고/Big Data2015.08.23 23:30





flume error 해결 org.apache.hadoop.io.LongWritable"org.apache.hadoop.io.BytesWritable



해결에 참고한 내용



입력되는 값
문자열이 탭으로 구분된 데이터

sfae a;ldfja;sldj alwkejhfalskdhf a;slekjafabcd def de
ab d eef ddefsef
sfae a;ldfja;sldj alwkejhfalskdhf a;slekjafabcd def de
ab d eef ddefsef
sfae a;ldfja;sldj alwkejhfalskdhf a;slekjafabcd def de
ab d eef ddefsef
sfae a;ldfja;sldj alwkejhfalskdhf a;slekjaabcd def de
ab d eef ddefsef
sfae a;ldfja;sldj alwkejhfalskdhf a;slekjafabcd def de
ab d eef ddefsef
sfae a;ldfja;sldj alwkejhfalskdhf a;slekjaf
sfae a;ldfja;sldj alwkejhfalskdhf a;slekjafabcd def de
ab d eef ddefsef
sfae a;ldfja;sldj alwkejhfalskdhf a;slekjafabcd def de
ab d eef ddefsef
sfae a;ldfja;sldj alwkejhfalskdhf a;slekjafabcd def de
ab d eef ddefsef
sfae a;ldfja;sldj alwkejhfalskdhf a;slekjaabcd def de
ab d eef ddefsef
sfae a;ldfja;sldj alwkejhfalskdhf a;slekjafabcd def de





 에러로 출력되는 결과
SEQ!org.apache.hadoop.io.LongWritable"org.apache.hadoop.io.BytesWritable      €藪???pR??      NC+?   abcd def de      NC+?   ab d eef ddefsef   8    NC+?   ,sfae a;ldfja;sldj alwkejhfalskdhf a;slekjaf      NC+?   abcd    def     de   +    NC+?   ab      d       eef     ddefsef   O    NC+?   Csfae    a;ldfja;sldj    alwkejhfalskdhf a;slekjafabcd    def     de   +    NC+?   ab      d       eef     ddefsef   O    NC+?   Csfae    a;ldfja;sldj    alwkejhfalskdhf a;slekjafabcd    def     de   +    NC+?   ab      d       eef     ddefsef   O    NC+?   Csfae    a;ldfja;sldj    alwkejhfalskdhf a;slekjafabcd    def     de








아래 설정에서 파란색 라인을 추가 하는 것으로 해결됨

agent.sources = logfilereadSource
agent.channels = memoryChannel
agent.sinks = loggerSink

# source
# For each one of the sources, the type is defined
agent.sources.logfilereadSource.type = exec
agent.sources.logfilereadSource.command = tail -F /home/hadoop/download/flumeTestfile.log
agent.sources.logfilereadSource.batchSize = 10
agent.sources.logfilereadSource.channels = memoryChannel

# channel
agent.channels.memoryChannel.type = memory
agent.channels.memoryChannel.capacity = 20480


# Sink
#Specify the channel the sink should use
agent.sinks.loggerSink.type = hdfs
agent.sinks.loggerSink.channel = memoryChannel
agent.sinks.loggerSink.hdfs.path = hdfs://localhost:8020/user/admin/flumetest/log
agent.sinks.loggerSink.hdfs.fileType = DataStream
agent.sinks.loggerSink.serializer = com.adaltas.flume.serialization.HeaderAndBodyTextEventSerializer$Builder
agent.sinks.loggerSink.serializer.format = CSV
agent.sinks.loggerSink.serializer.appendNewline = true
agent.sinks.loggerSink.serializer.delimiter = '\t'


위 설정 추가후

ab d eef ddefsef sfae a;ldfja;sldj alwkejhfalskdhf a;slekjafabcd def de ab d eef ddefsef sfae a;ldfja;sldj alwkejhfalskdhf a;slekjafabcd def de ab d eef ddefsef sfae a;ldfja;sldj alwkejhfalskdhf a;slekjaabcd def de ab d eef ddefsef sfae a;ldfja;sldj alwkejhfalskdhf a;slekjafabcd def de ab d eef ddefsef sfae a;ldfja;sldj alwkejhfalskdhf a;slekjaf





신고





Posted by 파란물
보물창고/Programming2011.09.22 22:46







안드로이드 에러, 디바이스에서는 되는데 에뮬에서 안될때 [android, error, device]

안드로이드 에러 중 디바이스에서는 잘 되다가 에뮬에서 안될때 한번쯤 확인 해볼 사항 입니다









 

09-22 07:56:28.315: ERROR/AndroidRuntime(813): FATAL EXCEPTION: main

09-22 07:56:28.315: ERROR/AndroidRuntime(813): java.lang.RuntimeException: Unable to start activity ComponentInfo{ibm.cw.f5/ibm.cw.f5.TestJSActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class android.widget.LinearLayout

09-22 07:56:28.315: ERROR/AndroidRuntime(813):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1622)

09-22 07:56:28.315: ERROR/AndroidRuntime(813):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1638)

09-22 07:56:28.315: ERROR/AndroidRuntime(813):     at android.app.ActivityThread.access$1500(ActivityThread.java:117)

09-22 07:56:28.315: ERROR/AndroidRuntime(813):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:928)

09-22 07:56:28.315: ERROR/AndroidRuntime(813):     at android.os.Handler.dispatchMessage(Handler.java:99)

09-22 07:56:28.315: ERROR/AndroidRuntime(813):     at android.os.Looper.loop(Looper.java:123)

09-22 07:56:28.315: ERROR/AndroidRuntime(813):     at android.app.ActivityThread.main(ActivityThread.java:3647)

09-22 07:56:28.315: ERROR/AndroidRuntime(813):     at java.lang.reflect.Method.invokeNative(Native Method)

09-22 07:56:28.315: ERROR/AndroidRuntime(813):     at java.lang.reflect.Method.invoke(Method.java:507)

09-22 07:56:28.315: ERROR/AndroidRuntime(813):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)

09-22 07:56:28.315: ERROR/AndroidRuntime(813):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)

09-22 07:56:28.315: ERROR/AndroidRuntime(813):     at dalvik.system.NativeStart.main(Native Method)

09-22 07:56:28.315: ERROR/AndroidRuntime(813): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class android.widget.LinearLayout

09-22 07:56:28.315: ERROR/AndroidRuntime(813):     at android.view.LayoutInflater.createView(LayoutInflater.java:518)

09-22 07:56:28.315: ERROR/AndroidRuntime(813):     at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)

09-22 07:56:28.315: ERROR/AndroidRuntime(813):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)

09-22 07:56:28.315: ERROR/AndroidRuntime(813):     at android.view.LayoutInflater.inflate(LayoutInflater.java:386)

09-22 07:56:28.315: ERROR/AndroidRuntime(813):     at android.view.LayoutInflater.inflate(LayoutInflater.java:320)

09-22 07:56:28.315: ERROR/AndroidRuntime(813):     at android.view.LayoutInflater.inflate(LayoutInflater.java:276)

09-22 07:56:28.315: ERROR/AndroidRuntime(813):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207)

09-22 07:56:28.315: ERROR/AndroidRuntime(813):     at android.app.Activity.setContentView(Activity.java:1657)

09-22 07:56:28.315: ERROR/AndroidRuntime(813):     at ibm.cw.f5.TestJSActivity.onCreate(TestJSActivity.java:34)

09-22 07:56:28.315: ERROR/AndroidRuntime(813):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)

09-22 07:56:28.315: ERROR/AndroidRuntime(813):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1586)

09-22 07:56:28.315: ERROR/AndroidRuntime(813):     ... 11 more

09-22 07:56:28.315: ERROR/AndroidRuntime(813): Caused by: java.lang.reflect.InvocationTargetException

09-22 07:56:28.315: ERROR/AndroidRuntime(813):     at java.lang.reflect.Constructor.constructNative(Native Method)

09-22 07:56:28.315: ERROR/AndroidRuntime(813):     at java.lang.reflect.Constructor.newInstance(Constructor.java:415)

09-22 07:56:28.315: ERROR/AndroidRuntime(813):     at android.view.LayoutInflater.createView(LayoutInflater.java:505)

09-22 07:56:28.315: ERROR/AndroidRuntime(813):     ... 21 more

09-22 07:56:28.315: ERROR/AndroidRuntime(813): Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget

09-22 07:56:28.315: ERROR/AndroidRuntime(813):     at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)

09-22 07:56:28.315: ERROR/AndroidRuntime(813):     at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:450)

09-22 07:56:28.315: ERROR/AndroidRuntime(813):     at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:326)

09-22 07:56:28.315: ERROR/AndroidRuntime(813):     at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:697)

09-22 07:56:28.315: ERROR/AndroidRuntime(813):     at android.content.res.Resources.loadDrawable(Resources.java:1709)

09-22 07:56:28.315: ERROR/AndroidRuntime(813):     at android.content.res.TypedArray.getDrawable(TypedArray.java:601)

09-22 07:56:28.315: ERROR/AndroidRuntime(813):     at android.view.View.<init>(View.java:1951)

09-22 07:56:28.315: ERROR/AndroidRuntime(813):     at android.view.View.<init>(View.java:1899)

09-22 07:56:28.315: ERROR/AndroidRuntime(813):     at android.view.ViewGroup.<init>(ViewGroup.java:286)

09-22 07:56:28.315: ERROR/AndroidRuntime(813):     at android.widget.LinearLayout.<init>(LinearLayout.java:120)

09-22 07:56:28.315: ERROR/AndroidRuntime(813):     ... 24 more

 


디바이스에서는 되는데 에뮬에서 안되면고 위와 같은 에러를 표시하고 있었습니다.
에러가 정확하게 해석되지 않아 차근차근 하나씩 확인하면서 보니 이미지 해상도에 문제가 있었습니다.










배경과 버튼으로 사용할 이미지 해상도가 화면에 보이는것보다 1.5배에서 3배 이상 크게 만들었던게 문제였습니다


 

원래 필요 했던 이미지 사이즈


 

제작된 이미지 사이즈(클릭하시면 원래 큰 사이즈를 볼 수 있습니다)




이미지가 워낙 크다보니 xml레이아웃에서도 제대로 보이지 않아 이상하다 생각 했었습니다. 사이즈를 정확하게 줄이고 나니 레이아웃에도 정확하게 표시되고 에뮬에서도 에러없이 샐행 하는 모습을 볼 수 있었습니다

혹시나 에뮬에서 확인 안되는 에러나 나타난다면 확인해 보세요!



신고





Posted by 파란물
보물창고/Programming2011.08.24 17:31








안드로이드 에러
The constructor Intent(new View.OnClickListener(){}, Class<DongProject2Activity>) is undefined







 

public class FaceBookLogin extends Activity {

    Facebook facebooknew Facebook("102663696505918");

    String faceBookLoginMeId = "";

    //String faceBookLoginMeEmail = "";

    @Override

    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        //setContentView(R.layout.facebookloginmain);

        setContentView(R.layout.facebookloginmain);

        faceBookGetId();     //페이스북 접속후 아이디 가져오는

        Button mainButton1 = (Button)findViewById(R.id.button);

        mainButton1.setOnClickListener(new OnClickListener() {

            @Override

            public void onClick(View v) {

                Log.v("log","mainButton1 ++++++++++++++++++++++ : " + v);

        Intent intent = new Intent(this, DongProject2Activity.class);

               startActivity(intent);     //페이지 넘김

            }

        });

    } 

 

위에 빨간 글씨처럼 에러나 나고 있어서 구글링으로 해결 했습니다







 

   Intent intent = new Intent(FaceBookLogin.this, DongProject2Activity.class);



this앞에 클래스 이름을 붙여 해결 했습니다








참고한 페이지
 
http://www.androidpub.com/877312

신고





Posted by 파란물
보물창고/Programming2011.03.06 18:05








error C2533: 'Sum::{ctor}' : 생성자에서 반환 형식을 사용할 수 없습니다.





class Sum
{
 public:
 int i, j;

 Sum(); //생성자
  
} ;

클래스 생성시 ; 이것으로 닫지 않았을때 나오는 에러 입니다




 

저작자 표시 비영리 변경 금지
신고





Posted by 파란물