w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
how can implement Right Arithmatic Shift in 8051 microcontroller only using RR A and RRC A?
It's been a long time since I did 8051, but I think you need: mov C, ACC.7 rrc A That is, pre-load carry with the sign bit of the accumulator, and then shift A right, and copy the carry (the old sign bit) into the new sign bit position.

Categories : Misc

8051 include file setting in eclipse
Inside the folder where the toolchain is installed, you should have a folder called "include". Check if 8051.h is in the "root" folder, inside /include. If not, look for it. You must add the path to the include. Let's say the file is in /arch/8051.h, your include becomes: #include <arch/8051.h> void delay() { //stuff

Categories : Eclipse

How to select every year from a particular year to the current year as different rows?
The easiest thing for you to do would be to create a numbers table that you would use for these types of queries. You could also use a recursive Common Table Expression to generate the list of years: ;with cte (yr) as ( select 2000 union all select yr + 1 from cte where yr+1 <=2013 ) select yr from cte; See SQL Fiddle with Demo

Categories : Sql Server

Sending a stored value register over serial in assembly and 8051
3 candiates Most likely: The strange character you received in hyper-term are in fact the data your 8051 is sending. Since the 8051 may send bytes with code 128 - 255, the area outside the ASCII as well as unprintable ASCII in range of 0 - 31 (except 10,13), hyper-term is using some interesting characters to display these bytes. e. g. Partial code character table follows. Note other code to character mappings exist. 128 € 129 ? 130 ‚ 131 ƒ 132 „ 133 … 134 † 135 ‡ 136 ˆ 137 ‰ Sender/receiver are not using the same parity/stop/bit length settings. Insure both are using the same number of bits/word (8), stop bits (1) and parity setting (suggest "none"). Mis-match baud. Unusual but the 8051 may be using transmit baud different from receive baud. (not likely) Que

Categories : Assembly

How do you embed Java into a microcontroller?
Java and C are very, very different langauges. You'll need to find a compiler for your microcontroller that supports Java. However, if your controller can get C compiled via GCC, then use of GCJ may work with certain memory constraints on the target platform. You'll need to generate an object file of the correct architecture, and link it using microcontroller-compatible gcc. This is not worth its time. I recommend implementing it in C instead. Besides, opening files and sockets may not occur since a microcontroller usually does not provide any kernel routines beyond certain aspects of hardware access. libc will also likely be absent or minimal. You might also not have networking hardware. If you can tell us which microcontroller, we could help.

Categories : Java

Any possible way to re-program a USB drive's microcontroller?
What I was thinking was if one could reprogram them to say, start an application upon insertion into a USB port, then it could be useful for a multitude of applications (such as copying files automatically). You are mistaken. When you reprogram a USB flash microcontroller, you cause a program to run inside the USB flash stick. You do NOT cause any program to run on the computer's main processor. The USB flash stick's processor only interacts with the main computer by responding to USB transactions initiated by the USB host controller in the main computer, which is under the control of the OS. In effect, your capabilities are limited to changing what kind of USB device it is reported as (mass storage or imaging or network or ...) and changing the content of the data returned when t

Categories : Assembly

PostgreSQL - show data of previous year + current year's week
Basic query for running sum Use the well-known aggregate function sum() as window function. SELECT week, x.last_year_profit + y.running_profit AS week_profit FROM ( -- total last year SELECT sum(profit) AS last_year_profit FROM sale_order WHERE date_order >= date_trunc('year', now() - interval '1 year') AND date_order < date_trunc('year', now()) ) x CROSS JOIN ( -- running sum current year SELECT date_trunc('week', date_order) AS week ,sum(sum(profit)) OVER (ORDER BY date_trunc('week', date_order)) AS running_profit FROM sale_order WHERE date_order >= date_trunc('year', now() - interval '1 year') AND date_order < date_trunc('year', now() + interval '1 year')

Categories : SQL

In R, how to select a year-specific datum from multiple year columns?
You could use a switch statement and a for loop: # Define a function to return which column the year refers to col_finder <- function(r1) { switch(r1, "2000"=1, "2001"=2, "2002"=3) } # Initiallize a new column x$yr.response2 <- NA # Switch statements are not vectorized, so run this in a for loop for(i in 1:nrow(x)) { cmn <- col_finder(as.character(x[i, "year"])) x[i, "yr.response2"] <- x[i, cmn] }

Categories : R

strtotime and DateTime giving wrong year when parsing a year
EDIT: different formats... try $date = '2012-11'; $parts = explode('-', $date); switch(count($parts)){ case 2: $format = 'Y-m'; break; case 3: $format = 'Y-m-d'; break; case 1: default: $format = 'Y'; break; } $date = DateTime::CreateFromFormat($format, $year); echo $date->format('Y');

Categories : PHP

Regex for finding strings with reasonable "Year/YEAR" pattern
Description This expression will: match all your sample cases, while avoiding the undesired cases comply with a java regex engine Note this does use the x option which ignores whitespace and comments in the expression (?:^|s)(?:Year|YEAR)(?:s||$) # match no prefix or suffix | (?:^|s)[A-Z][a-z]+[^a-zA-Zd]?(?:Year|YEAR)(?:s||$) # match title case prefix | (?:^|s)[A-Z]+[^a-zA-Zds](?:Year|YEAR)(?:s||$) # match all uppercase prefix | (?:^|s)[a-z]+[^a-zA-Zd](?:year)(?:s||$) # match all lower case prefix and keyword | (?:^|s)(?:Year|YEAR)[^a-zA-Zd]?[A-Z][a-z]+(?:s||$) # match title case suffix | (?:^|s)(?:Year|YEAR)[^a-zA-Zds][A-Z]+(?:s||$) # match all uppercase suffix Or as a single string: (?:^|s)(?:Year|YEAR)(?:s||$)|(?:^|s)[A-Z][a-z]+[^a-zA-Zd]?(?:Year|YEAR)(?:s||$)|(?:^|

Categories : Regex

issue with NSDate I am removing year but takes 0001 as year
Its OKAY, since you are not using NSYearCalendarUnit in your following code NSInteger desiredComponents = (NSDayCalendarUnit | NSMonthCalendarUnit); so NSDate is assuming 0001 as default year, if you add NSYearCalendarUnit in the above code it will give correct year, like below NSInteger desiredComponents = (NSDayCalendarUnit | NSMonthCalendarUnit | NSYearCalendarUnit);

Categories : IOS

Pyserial microcontroller to host communication
I have not used beaglebone. I have worked with arduino's serial I/O. But this post says you have multiple serial I/O ports on BBB. Find appropriate connectors/convertors for serial to USB. Then use the pyserial python module. On OSX, you will find your device when connected on a path like /dev/ttyo1 where dev is my system name and ttyo1 or something similar will be your device. import serial as s device = "/dev/tty01" bbb = s.Serial(device, 4800) #the second param is baudrate while(True): bbb.readline() # do what you want with the output. bbb.write('input') This will read till the end of line character and give you a string. and then write "input" to the serial io on bbb. You will need a similar program running on BBB to read this input and do what you want to do with it.

Categories : Python

Ascii String Encryption on Microcontroller
If you don't mind your strings growing a little you could replace 0x00 bytes with 0x01 0x01 and 0x01 bytes with 0x01 0x02 during the encode. At the far end you can then replace 0x01 0x01 with 0x00 and 0x01 0x02 with 0x01 during the decode. For example: 0x04 0x00 0x05 0x01 would turn into 0x04 0x01 0x01 0x05 0x01 0x02 during transmission.

Categories : C

MySQL: Convert year-by-year rows to columns?
...I see a technique for getting this done now, but I don't yet get why my technique failed. Any insight there?... You have to use an aggregate function (SUM(), MIN(), MAX() depending on your needs) and GROUP BY Try SELECT personid, SUM(CASE WHEN yearID = 1999 THEN event1 ELSE 0 END) event1_1999, SUM(CASE WHEN yearID = 2000 THEN event1 ELSE 0 END) event1_2000, SUM(CASE WHEN yearID = 2001 THEN event1 ELSE 0 END) event1_2001 FROM Table1 GROUP BY personid Same thing but with IF SELECT personid, SUM(IF(yearID = 1999, event1, 0)) event1_1999, SUM(IF(yearID = 2000, event1, 0)) event1_2000, SUM(IF(yearID = 2001, event1, 0)) event1_2001 FROM Table1 GROUP BY personid Output in both cases | PERSONID | EVENT1_1999 | EVENT1_2000 | EVENT1_20

Categories : Mysql

I need to select Year, AVG(score) where COUNT(id) is more than 1 grouped by year
Do you mean this? Select Year, AVG(score) FROM movies GROUP BY year HAVING count(*) > 1 ORDER BY year desc; The use of desc on group by is very MySQL specific. I think it is better to have an explicit order by.

Categories : SQL

What is lightweight text editor that i can port on a microcontroller?
My suggestion is to use a graphics library and fashion a "simple as you like" line editor. Outline Mr Microchip has a free Graphics Display Designer program which will generate code for all the display driving primitives in various modes. (ie VGA mono and would use a graphics controller) Then I suggest (starting with) three display elements ( four lines of pre-context, one line of segment to edit and four lines of post context) which can be made out of static text boxes and an edit box (if line is longer than the display width, then line is broken into multiple segments ) So on initial read of your file the pre-context would be empty and the first segment would be the first line upto the display width. The post context would be made from the balance of the first line or subsequent lin

Categories : Misc

Printf output using UART in ARM Cortex-M3 microcontroller
Your fputc sends bytes directly to the UART, which goes to the RS232 connector on board. If you want to see the output of your fputc, you need to connect a cable between the board and the PC and see it with a client such as hyperterminal. When you talk about the trace capabilities, it generally means that the adapter (J-Link in your case) creates high throughput communication between the program and the debugger and follows the execution of the program. There are other debug functionalities. For example if you compile with semihosting, the program executes the system calls (_write, _open, ...) that are intercepted by the debugger that executes them on the host machine. So in my experience either you call printf, don't override the fputc and compile with semihosting, and expect the output

Categories : C

Atmel microcontroller: difference between UBRR0H and UBRRnH
In Nut/OS, I see this #define: #define UBRRnH UBRR0H It's entirely possible that they are equivalent.

Categories : C

Where can i get am335x microcontroller board registers header file?
please refer to the device datasheet for device registers: http://www.ti.com/litv/pdf/spruh73i In Linux each device driver has it's own internal definitions of registers for which it has appropriate access rights. There is no unique place which defines all peripheral registers like Atmel does.

Categories : Misc

CJuiDatePicker year/year-month/year-month-day selection
I would try to set all three Datepickers and hide()/show() them depending on your needs (with a dropdown or something like that..). You can also try to append() to the datepicker a bar menu with three buttons to switch between the modes. Good luck!

Categories : Javascript

Mysql Select events from last year but not this year
No joins required; just filter the orders when grouped on customer: SELECT CustomerID FROM Orders GROUP BY CustomerID HAVING SUM(OrderDate BETWEEN 2012-03-01 AND 2012-03-31) AND NOT SUM(OrderDate BETWEEN 2013-01-01 AND 2013-12-31)

Categories : PHP

SQL Ranking Dates to Get Year Over Year Order
select T.YearMonth, rank() over (order by R.rnk asc, D.YearNumber desc) as [Rank], D.MonthNumber, D.YearNumber from Table1 as T outer apply ( select month(getdate()) as CurMonthNumber, cast(right(T.YearMonth, 2) as int) as MonthNumber, cast(left(T.YearMonth, 4) as int) as YearNumber ) as D outer apply ( select case when D.MonthNumber <= D.CurMonthNumber then D.CurMonthNumber - D.MonthNumber else 12 + D.CurMonthNumber - D.MonthNumber end as rnk ) as R sql fiddle example

Categories : SQL

Generating Logarithmically Spaced Values on an Operation Limited Microcontroller
based on the 10 bit ADC read. This ADC can output only 1024 different values (0-1023), so you can use a table of 1024 16-Bit values, which would consume 2KB Flash memory: const uint16_t LogarithmicTable[1024] = { 0, 1, ... , 64380}; Calculating the logarithmic output is now a simple array access: result = LogarithmicTable[ADC_READ]; You can use a tool like Excel to generate the constants in this Table for you.

Categories : C

Mapping Sparse Lookup Table to Function Pointer Array in C on MicroController
Create an array somewhat larger than the number of opcodes used (maybe 1.5 to 2X). Create hash function to index into array. Re-check entry from hash index. If not a match, look to next entry. Keep looking until you find the correct one. With a big enough table, you shouldn't have too many collisions.

Categories : C

Year Over Year (YOY) Distinct Count
Concept using an existing query I have done something similar for finding out the number of distinct customers who bought something in between years, I modified it to use your concept of year, the variables you add would be that start day and start month of the year and the start year and end year. Technically there is a way to avoid using a loop but this is very clear and you can't go past year 9999 so don't feel like putting clever code to avoid a loop makes sense Tips for speeding up the query Also when matching dates make sure you are comparing dates, and not comparing a function evaluation of the column as that would mean running the function on every record set and would make indices useless if they existed on dates (which they should). Use date add on zero to initiate your ta

Categories : SQL

i need to group years and select last five years with the averages of each year so that i have average and year output
I think your subquery does what you want: SELECT Year AS yr, AVG( "tbltest.AskingPrice" ) AS AP FROM tbltest GROUP BY `yr` ORDER BY Year DESC LIMIT 5; I just moved the desc to the order by to be consistent with standard SQL.

Categories : Java

Merging country-year data into directed dyad-year data in R
1. Just CY This can be done using only CY like this: library(sqldf) sqldf("select A.country country1, B.country country2, year, A.x x1, B.x x2 from CY A join CY B using (year) where A.country != B.country order by A.country, B.country") which gives: country1 country2 year x1 x2 1 A B 1990 6.2352 2.2342 2 A B 1991 7.2342 5.1292 3 A B 1992 8.3902 1.0001 4 A C 1990 6.2352 4.1202 5 A C 1991 7.2342 9.1202 6 A C 1992 8.3902 1.2011 7 A D 1990 6.2352 1.2910 8 A D 1991 7.2342 5.0001 9 A D 1992 8.3902 2.1111 10 B A 1990 2.2342 6.2352 11 B A 1991 5.1292 7.2342 12 B A 1992 1.0001 8.3902 13 B

Categories : R

How to convert numeric year month to year-month-day date format in xts?
Use the yearmon class and then as.Date.yearmon to quote from help('yearmon'): as.Date.yearmon and as.yearmon.yearqtr each has an optional second argument of "frac" which is a number between 0 and 1 inclusive that indicates the fraction of the way through the period that the result represents. The default is 0 which means the beginning of the period. as.Date(as.yearmon(as.character(df$date), format = '%Y%m'), frac=1) ## [1] "1989-12-31" "1990-01-31" "1990-02-28" "1990-03-31"

Categories : R

What is the execution time for a double multiplication on a 16 bit microcontroller with only multiplication hardware support?
I ran through a two scenarios, 32 bit float computation and 64 bit computation. The Platform was on a 16 bit Renesas M16C/28 MCU ( this platform has a multiplier, but no floating point hardware. running at 20 Mhz, 1 cycle = 50 ns. Note: this was done with software so timing isn't perfect, but the idea and concept is proven in it. Scenario 1: void floatMultiple(void) { float a = 123456.1234; float b = 123456.1234; float result = 0; result = a * b; } timing in cycles Best case: 305(15.25uSec) worse case: 2033(101.65uSec) Scenario 2: void doubleMultiple(void) { double a = 123456.1234; double b = 123456.1234; double result = 0; result = a * b; } Using the same numbers same system, only changing the type. Best case: 2356(117.8uSec) worse case: 1456

Categories : Performance

year n+1 < year n in excel vba
It is clear that in the For loop you are comparing the dates as strings, so I am not surprised that you get different results. You should change If Format(CDate(booking.Cells(L, 5).Value), "dd-mm-yy") < Format(CDate(cells(1,10).value), "dd-mm-yy") Then to If booking.Cells(L, 5).Value < booking.Cells(1,10) Then on unrelated note, what is the value of variable cells in the second part of your If statement? Did you forget to precede it with booking.?

Categories : Excel

Can one apply iOS Developer Program ($99/year) and iOS Developer Enterprise Program ($299/year) at the same time?
Nope. Its not possible. If you are already registered for iOS Developer program then you want to go for the Enterprise program then you have to contact Apple for that. Contact Apple If you are already registered for the iOS Enterprise program then you must have to setup new account for iOS developer program. Q : I am already enrolled in the iOS Developer Enterprise Program. Can I add the iOS Developer Program to my existing account? A : No. If you would like to distribute apps on the App Store, you must set up a new Apple ID to enroll in the iOS Developer Program. For more info refer Program Enrollment

Categories : IOS

Linux/Unix - Setting default file/folder permissions using ACL, executable permission not setting?
It's not setting the execute bit because files are only created with execute permission if the application explicitly requests it. Since it makes no sense to make an .html file executable, whatever program created it did not request execute permission to be added, so it has no execute permission. Consequently, execute permission from the default ACL effectively only applies to directories, not to files. As for why the default group is not set to ftp, this is more subtle. The default ACL is just that -- an ACL. It's not a default group ownership. As such it shows up not in ls but in getfacl: # mkdir public # setfacl -R -m u::rwx,g:ftp:rwx,d:g:ftp:rwx,o::rx public/ # getfacl public # file: public # owner: root # group: root user::rwx group::r-x group:ftp:rwx mask::rwx other::r-x defa

Categories : Linux

Setting value to a input field using Jquery val not working.I have commented out code setting value in edit() function
check this fiddle js fiddle here is the code that i have modified. function edit(id){ $("#firstName").val(data[id].firstName); $("#lastName").val(data[id].lastName); $("#city").val(data[id].city); $("#state").val(data[id].state); $("#pin").val(data[id].pin); }

Categories : Javascript

Rails form_for setting options and setting selected option
The parameters of f.select are: attribute_name,option_tags,options. option_tags is supposed to be a string of html option tags. There are some helpers to construct such a string from i.e. an array of values, a collection etc.: options_for_select, options_from_selection_for_select. You have to use one of these helpers. You can get the existing vehicle_sizees with: Model.pluck(:vehicle_size).uniq so your select could look like: <%= f.select :vehicle_size, options_for_select(Model.pluck(:vehicle_size).uniq,@model.vehicle_size) %> See the Rails Guide on form helpers.

Categories : Mysql

How to show setting flyout by using button instead of setting charms
You can find the AppBar using Page.BottomAppBar and use FindName method to find a specific button and add a handler to that. The only point is you are currently creating your SettingFlyout inside an anonymous function, so only place you can do that would be inside your anonymous function.

Categories : C#

Setting css with jquery losing setting after page refresh
Use cookie for this $(function(){ var cookieval = $.cookie('cookie-key'); if (cookieval === 'something'){ //here restore style } });

Categories : CSS

What's the rule for preg_match() setting an empty string or not setting?
It depends on whether you make the whole capturing group optional or not. If you make the group required but allow it to match the empty string then the match will always be set, but might be empty: preg_match('/(d)(d?)/', '1', $matches); // $matches[2] === '' If you make the group optional by moving the quantifier ? outside the brackets, the match will be set conditionally: preg_match('/(d)(d)?/', '1', $matches); // no $matches[2]

Categories : PHP

SharePoint 2010 - setting peoplepicker-searchadforests, unable to remove property and get after setting with no -url param
Since this is a per Web Application property, did you try to run command supplying URLs for each Web Application which you have in the farm (including Central Admin)? Alternatively, did you clear configuration cache? If you don't see a problem in your local environment test, as this is per Web Application setting, I would believe you'll be good in production as well.

Categories : Sharepoint

Setting Constraints programmatically different from setting them in IB?
Here's how I would do this: [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[redView]|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(redView)]]; [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[redView]|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(redView)]]; AutoLayout in IB can be a pain and I found th

Categories : IOS

Does setting a password on the postgres user mean that a password is required even when setting pg_hba.conf to trust?
Change your pg_hba.conf to: local all postgres trust local all all trust host all all 127.0.0.1/32 trust host all all ::1/128 trust This will allow you to connect without password. Remember to restart (or reload) postgresql after you edit pg_hba.conf. In alternative, you can try to change your php code like this: pg_connect('dbname=dev user=postgres'); This should work even without any change to pg_hba.conf. Explanation: You can connect to postgres via unix socket (suggested, faster) or via TCP/IP. The first and second line in pg_hba.conf are relative to socket, the third to ipv4 and the fourth to ipv6. If

Categories : PHP



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.